我有以下代碼。我試圖獲取有關我所連接的遠程計算機是32位還是64位的信息。我試着在這段代碼的最後一段執行它,但它不起作用。以下是錯誤(我改變了遠程系統名稱):拉VBScript中的遠程Windows服務器體系結構
WshShell.RegRead:在註冊表無效的根密鑰 「\ * remotesystem * \ HKEY_LOCAL_MACHINE \ SYSTEM \ CurrentCon trolSet \控制\會話管理\環境\ PROCESSOR_ARCHITECTURE」。
Option Explicit
Dim objWMISrvc,strRemoteComputer,colOSItems,objItem,args,OsType
'String variables
Dim strName,strCaption,strVersion,strCSDVer,strSerial,WshShell
'Adding this in to transfer FQDN variable to this script from ASP.net
Set args = WScript.Arguments
strRemoteComputer = args.Item(0)
Set objWMISrvc = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strRemoteComputer & "\root\cimv2")
CheckOSType objWMISrvc
Sub CheckOSType(objWMISrvc)
Set colOSItems = objWMISrvc.ExecQuery("Select * from Win32_OperatingSystem",,48)
For Each objItem in colOSItems
strName = objItem.CSName
'strDesc = objItem.Description
'strManufac = objItem.Manufacturer
strCaption = objItem.Caption
strVersion = objItem.Version
strCSDVer = objItem.CSDVersion
strSerial = objItem.SerialNumber
Next
Set WshShell = CreateObject("WScript.Shell")
OsType = WshShell.RegRead("\\" & strRemoteComputer & "\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment\PROCESSOR_ARCHITECTURE")
If OsType = "x86" then
WScript.Echo "Windows 32bit system detected"
elseif OsType = "AMD64" then
WScript.Echo "Windows 64bit system detected"
end if
End Sub