名称:强制 VBS 以 32 位模式运行
功能:修正 VBS 在 Windows 7 等 64 位系统中无法调用32位组件的问题 | RunAsX64 | | Test | | | | Sub Test() | | Set sc = CreateObject("ScriptControl") | | sc.Language = "javascript" | | t = sc.eval("new Date().getTime()") | | Msgbox t | | End Sub | | | | | | | | | | Sub RunAsX64() | | On Error Resume Next | | If InStr(1,WScript.FullName,"\SysWOW64\",vbTextCompare) > 0 Then Exit Sub | | Dim wso, sCommand, sArgs | | Set wso = CreateObject("WScript.Shell") | | If wso.Run("cmd /c set ProgramFiles|find /i ""x86"" ",0,True) = 0 Then | | If Err.Number = 0 Then | | sCommand = "%windir%\SysWOW64\cscript.exe //NoLogo """ & WScript.ScriptFullName & """" | | For Each oArg In WScript.Arguments | | sArgs = sArgs & " " & """" & oArg & """" | | Next | | wso.Run sCommand & sArgs, 1, False | | WScript.Quit | | End If | | End If | | End SubCOPY |
| | | | | | | Function Is64OS() | | On Error Resume Next | | Is64OS = False | | Set wso = CreateObject("WScript.Shell") | | If wso.Run("cmd /c set ProgramFiles|find /i ""x86"" ",0,True) = 0 Then | | If Err.Number = 0 Then Is64OS = True | | End If | | End FunctionCOPY |
|