Jak uruchomić VBScript w trybie 32-bitowym na 64-bitowym komputerze?
Mam plik tekstowy, który kończy się na .vbs, w którym napisałem:
Set Conn = CreateObject("ADODB.Connection")
Conn.Provider = "Microsoft.ACE.OLEDB.12.0"
Conn.Properties("Data Source") = "C:\dummy.accdb"
Conn.Properties("Jet OLEDB:Database Password") = "pass"
Conn.Open
Conn.Close
Set Conn = Nothing
- kiedy wykonuję to na 32-bitowym komputerze z systemem Windows, uruchamia się i kończy bez żadnego pojęcia (oczekiwanego).
- kiedy wykonam to na 64-bitowej maszynie Windows, dostaje błąd
Nie można znaleźć dostawcy. Może nie być prawidłowo zainstalowany.
Ale jest zainstalowany. Myślę, że głównym problemem jest to, że dostawca jest dostawcą 32-bitowym, o ile wiedz, że nie istnieje jako 64-bit.
Jeśli uruchamiam VBScript przez IIS na moim 64-bitowym komputerze (jako plik ASP), mogę wybrać, że powinien działać w trybie 32-bitowym. Następnie może znaleźć dostawcę.
Jak mogę znaleźć dostawcę w systemie Windows 64-bit? Czy mogę powiedzieć CScript (który wykonuje .plik tekstowy VBS) do uruchomienia w trybie 32-bitowym jakoś?
7 answers
Follow http://support.microsoft.com/kb/896456
Aby uruchomić 32-bitowy wiersz polecenia, wykonaj następujące kroki:
* Click Start, click Run, type %windir%\SysWoW64\cmd.exe, and then click OK.
Następnie wpisz
cscript vbscriptfile.vbs
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2010-05-10 21:37:55
Jeśli masz kontrolę nad uruchomieniem pliku wykonywalnego cscript, uruchom wersję X:\windows\syswow64\cscript.exe
, która jest 32-bitową implementacją.
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2010-05-10 21:35:04
' C:\Windows\System32\WScript.exe = WScript.exe
Dim ScriptHost : ScriptHost = Mid(WScript.FullName, InStrRev(WScript.FullName, "\") + 1, Len(WScript.FullName))
Dim oWs : Set oWs = CreateObject("WScript.Shell")
Dim oProcEnv : Set oProcEnv = oWs.Environment("Process")
' Am I running 64-bit version of WScript.exe/Cscript.exe? So, call script again in x86 script host and then exit.
If InStr(LCase(WScript.FullName), LCase(oProcEnv("windir") & "\System32\")) And oProcEnv("PROCESSOR_ARCHITECTURE") = "AMD64" Then
' rebuild arguments
If Not WScript.Arguments.Count = 0 Then
Dim sArg, Arg
sArg = ""
For Each Arg In Wscript.Arguments
sArg = sArg & " " & """" & Arg & """"
Next
End If
Dim sCmd : sCmd = """" & oProcEnv("windir") & "\SysWOW64\" & ScriptHost & """" & " """ & WScript.ScriptFullName & """" & sArg
WScript.Echo "Call " & sCmd
oWs.Run sCmd
WScript.Quit
End If
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2014-01-27 12:32:57
' ***************
' *** 64bit check
' ***************
' check to see if we are on 64bit OS -> re-run this script with 32bit cscript
Function RestartWithCScript32(extraargs)
Dim strCMD, iCount
strCMD = r32wShell.ExpandEnvironmentStrings("%SYSTEMROOT%") & "\SysWOW64\cscript.exe"
If NOT r32fso.FileExists(strCMD) Then strCMD = "cscript.exe" ' This may not work if we can't find the SysWOW64 Version
strCMD = strCMD & Chr(32) & Wscript.ScriptFullName & Chr(32)
If Wscript.Arguments.Count > 0 Then
For iCount = 0 To WScript.Arguments.Count - 1
if Instr(Wscript.Arguments(iCount), " ") = 0 Then ' add unspaced args
strCMD = strCMD & " " & Wscript.Arguments(iCount) & " "
Else
If Instr("/-\", Left(Wscript.Arguments(iCount), 1)) > 0 Then ' quote spaced args
If InStr(WScript.Arguments(iCount),"=") > 0 Then
strCMD = strCMD & " " & Left(Wscript.Arguments(iCount), Instr(Wscript.Arguments(iCount), "=") ) & """" & Mid(Wscript.Arguments(iCount), Instr(Wscript.Arguments(iCount), "=") + 1) & """ "
ElseIf Instr(WScript.Arguments(iCount),":") > 0 Then
strCMD = strCMD & " " & Left(Wscript.Arguments(iCount), Instr(Wscript.Arguments(iCount), ":") ) & """" & Mid(Wscript.Arguments(iCount), Instr(Wscript.Arguments(iCount), ":") + 1) & """ "
Else
strCMD = strCMD & " """ & Wscript.Arguments(iCount) & """ "
End If
Else
strCMD = strCMD & " """ & Wscript.Arguments(iCount) & """ "
End If
End If
Next
End If
r32wShell.Run strCMD & " " & extraargs, 0, False
End Function
Dim r32wShell, r32env1, r32env2, r32iCount
Dim r32fso
SET r32fso = CreateObject("Scripting.FileSystemObject")
Set r32wShell = WScript.CreateObject("WScript.Shell")
r32env1 = r32wShell.ExpandEnvironmentStrings("%PROCESSOR_ARCHITECTURE%")
If r32env1 <> "x86" Then ' not running in x86 mode
For r32iCount = 0 To WScript.Arguments.Count - 1
r32env2 = r32env2 & WScript.Arguments(r32iCount) & VbCrLf
Next
If InStr(r32env2,"restart32") = 0 Then RestartWithCScript32 "restart32" Else MsgBox "Cannot find 32bit version of cscript.exe or unknown OS type " & r32env1
Set r32wShell = Nothing
WScript.Quit
End If
Set r32wShell = Nothing
Set r32fso = Nothing
' *******************
' *** END 64bit check
' *******************
Umieść powyższy kod na początku skryptu, a następny kod będzie działał w trybie 32-bitowym z dostępem do 32-bitowych sterowników ODBC. Źródło .
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2013-09-08 23:07:12
Możemy wymusić VBScript zawsze uruchamiany w trybie 32 bitowym, zmieniając "system32" na "syslow64" w domyślnej wartości klucza "Computer\HKLM\SOFTWARE]\Classes\VBSFile\Shell \ Open \ Command"
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2015-04-16 10:10:11
Alternatywna metoda uruchamiania 32-bitowych skryptów na 64-bitowej maszynie: %windir%\syslow64 \ cscript.exe vbscriptfile.vbs
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2014-05-08 11:06:13
W skrypcie launchera można go wymusić, pozwala to zachować ten sam skrypt i ten sam launcher dla obu architektur
:: For 32 bits architecture, this line is sufficent (32bits is the only cscript available)
set CSCRIPT="cscript.exe"
:: Detect windows 64bits and use the expected cscript (SysWOW64 contains 32bits executable)
if exist "C:\Windows\SysWOW64\cscript.exe" set CSCRIPT="C:\Windows\SysWOW64\cscript.exe"
%CSCRIPT% yourscript.vbs
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2015-05-12 10:47:35