I have a text file that ends with .vbs that I have written the following in:
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
Provider cannot be found. It may not be properly installed.
But it is installed. I think the root of the problem is that the provider is a 32-bit provider, as far as I know it doesn't exist as 64-bit.
If I run the VBScript through IIS on my 64-bit machine (as a ASP file) I can select that it should run in 32-bit mode. It can then find the provider.
How can I make it find the provider on Windows 64-bit? Can I tell CScript (which executes the .vbs text file) to run in 32-bit mode somehow?
WOW64 is the x86 emulator that allows 32-bit Windows-based applications to run seamlessly on 64-bit Windows. This allows for 32-bit (x86) Windows applications to run seamlessly in 64-bit (x64) Windows, as well as for 32-bit (x86) and 32-bit (ARM) Windows applications to run seamlessly in 64-bit (ARM64) Windows.
The 64-bit versions of Windows don't provide support for 16-bit binaries or 32-bit drivers. Programs that depend on 16-bit binaries or 32-bit drivers can't run on the 64-bit versions of Windows unless the program manufacturer provides an update for the program.
Click the Start button, and then click Run. In the Open field, type the full path of the script, and then click OK. You can also type WScript followed by the full name and path of the script you want to run.
follow http://support.microsoft.com/kb/896456
To start a 32-bit command prompt, follow these steps:
* Click Start, click Run, type %windir%\SysWoW64\cmd.exe, and then click OK.
Then type
cscript vbscriptfile.vbs
WScript.exe
exists in two versions, one in C:\Windows\System32\
and the other in C:\Windows\SysWOW64\
directories. They run respectively in 64 bits and 32 bits (against immediate logic but true).
You may add the following code at the beginning of your script so that it automatically starts again in 32 bits if it detects that it's called in 64 bits.
Note that it transmits the arguments if it calls itself to switch to 64 bits.
' 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
If you have control over running the cscript executable then run the X:\windows\syswow64\cscript.exe
version which is the 32bit implementation.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With