Getting System32 folder location with java
Asked Answered
F

3

6

On XP and above, my System32 folder is at C:\WINDOWS\system32. On Windows 2000 it is at C:\WINNT\system32. Is there a

System.getProperty("something");
or some way that I can get the location of the System32 folder?
Factfinding answered 2/12, 2010 at 19:36 Comment(0)
J
17

Since I think NT, the way to get it through environment variables is: %WINDIR%\system32

You can do this:

String sysdir = System.getenv("WINDIR") + "\\system32";

More default environment variables for windows on Wikipedia: http://en.wikipedia.org/wiki/Environment_variable#Examples_from_Microsoft_Windows

SYSTEMROOT and WINDIR are identical in NT systems, but WINDIR also works for older, 9x kernel-based windows.

Janeljanela answered 2/12, 2010 at 19:39 Comment(0)
B
4

This should work:

String system32Path = System.getenv("SystemRoot") + "\\system32";

On my installation of Windows XP, typing set SystemRoot in a Command Prompt returns C:\Windows

Banneret answered 2/12, 2010 at 19:41 Comment(0)
P
2

The environment variable SYSTEMROOT will give you the location of the windows install point (something like 'C:\Windows'). Construction of the full path to the System32 directory is of course, simple ('C:\Windows\System32').

Paget answered 2/12, 2010 at 19:40 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.