如何使用VBScript确定我运行的是32位还是64位Windows操作系统? [英] How can I use VBScript to determine whether I am running a 32-bit or 64-bit Windows OS?
问题描述
如何在VBScript中检测Windows操作系统的位数(32位和64位)?
How do i detect the bitness (32-bit vs. 64-bit) of the Windows OS in VBScript?
我尝试了这种方法,但是没有工作;我想(x86)会导致检查文件夹的问题。
I tried this approach but it doesn't work; I guess the (x86) is causing some problem which checking for the folder..
还有其他选择吗?
progFiles="c:\program files" & "(" & "x86" & ")"
set fileSys=CreateObject("Scripting.FileSystemObject")
If fileSys.FolderExists(progFiles) Then
WScript.Echo "Folder Exists"
End If
推荐答案
您可以查询 PROCESSOR_ARCHITECTURE
。 此处,您必须添加一些额外的检查,因为对于任何32位元, PROCESSOR_ARCHITECTURE
的值将为 x86
进程,即使它在64位OS上运行也是如此。在这种情况下,变量 PROCESSOR_ARCHITEW6432
将包含操作系统位数。 MSDN 。
You can query the PROCESSOR_ARCHITECTURE
. A described here, you have to add some extra checks, because the value of PROCESSOR_ARCHITECTURE
will be x86
for any 32-bit process, even if it is running on a 64-bit OS. In that case, the variable PROCESSOR_ARCHITEW6432
will contain the OS bitness. Further details in MSDN.
Dim WshShell
Dim WshProcEnv
Dim system_architecture
Dim process_architecture
Set WshShell = CreateObject("WScript.Shell")
Set WshProcEnv = WshShell.Environment("Process")
process_architecture= WshProcEnv("PROCESSOR_ARCHITECTURE")
If process_architecture = "x86" Then
system_architecture= WshProcEnv("PROCESSOR_ARCHITEW6432")
If system_architecture = "" Then
system_architecture = "x86"
End if
Else
system_architecture = process_architecture
End If
WScript.Echo "Running as a " & process_architecture & " process on a " _
& system_architecture & " system."
这篇关于如何使用VBScript确定我运行的是32位还是64位Windows操作系统?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!