How do i know in which drive windows is installed
-
i need to invoke a windows method. For this i call an exe file from windows\system32 directory. But i need to know in which drive winodws is installed. I think it is not wise to hard-code my code -"c:\windows\system32". So can any one tell me how do i know this path from my program in run time? Thanks
Chayan
-
i need to invoke a windows method. For this i call an exe file from windows\system32 directory. But i need to know in which drive winodws is installed. I think it is not wise to hard-code my code -"c:\windows\system32". So can any one tell me how do i know this path from my program in run time? Thanks
Chayan
I use
System.Environment.ExpandEnvironmentVariables
to expand%windir%
e.g. string MediaDir = System.Environment.ExpandEnvironmentVariables ( @"%windir%\Media\" ) ; -
i need to invoke a windows method. For this i call an exe file from windows\system32 directory. But i need to know in which drive winodws is installed. I think it is not wise to hard-code my code -"c:\windows\system32". So can any one tell me how do i know this path from my program in run time? Thanks
Chayan
Look for the
Windir
system variable in the environment variables...System.Environment.GetEnvironmentVariable("windir")
will return the string where Windows is installed :)"The clue train passed his station without stopping." - John Simmons / outlaw programmer
-
I use
System.Environment.ExpandEnvironmentVariables
to expand%windir%
e.g. string MediaDir = System.Environment.ExpandEnvironmentVariables ( @"%windir%\Media\" ) ;Hey, Thanks a lot for such quick response. It's really great !!! Thanks mate..:-D
Chayan
-
Look for the
Windir
system variable in the environment variables...System.Environment.GetEnvironmentVariable("windir")
will return the string where Windows is installed :)"The clue train passed his station without stopping." - John Simmons / outlaw programmer
Thanks mate for your great help. I am really happy to find such a simple and cool solution:-D. Thanks a lot !!!!
Chayan
-
i need to invoke a windows method. For this i call an exe file from windows\system32 directory. But i need to know in which drive winodws is installed. I think it is not wise to hard-code my code -"c:\windows\system32". So can any one tell me how do i know this path from my program in run time? Thanks
Chayan
A better solution is
System.Environment.GetFolderPath( System.Environment.SpecialFolder.System )
.Stability. What an interesting concept. -- Chris Maunder
-
A better solution is
System.Environment.GetFolderPath( System.Environment.SpecialFolder.System )
.Stability. What an interesting concept. -- Chris Maunder
Thanks a lot....Now i know multiple solutions to my problem..:)
Chayan