使用java获取System32文件夹位置

发布于 2024-10-05 21:44:13 字数 228 浏览 0 评论 0原文

在 XP 及更高版本上,我的 System32 文件夹位于 C:\WINDOWS\system32。在 Windows 2000 上,它位于 C:\WINNT\system32。有没有一个

System.getProperty("something");
or some way that I can get the location of the System32 folder?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

﹂绝世的画 2024-10-12 21:44:13

由于我认为是NT,通过环境变量获取的方法是: %WINDIR%\system32

你可以这样做:

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

维基百科上Windows的更多默认环境变量:http://en.wikipedia.org/wiki/Environment_variable#Examples_from_Microsoft_Windows

SYSTEMROOTWINDIR 是在 NT 系统中是相同的,但是 WINDIR 也适用于较旧的、基于 9x 内核的 Windows。

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.

柳若烟 2024-10-12 21:44:13

这应该有效:

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

在我安装的 Windows XP 中,在命令提示符中键入 set SystemRoot 返回 C:\Windows

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

独木成林 2024-10-12 21:44:13

环境变量 SYSTEMROOT 将为您提供 Windows 安装点的位置(例如“C:\Windows”)。构建 System32 目录的完整路径当然很简单('C:\Windows\System32')。

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').

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文