Reputation: 186
So at work we have a huge amount of legacy components, COM objects written in 32-bit VB6 and called through VBScript, and I've been assigned the wonderful job of maintaining and updating them. I've never worked in-depth with COM before but regardless I get set up, and try to run a script. I get the following error:
"Microsoft VBScript runtime error: ActiveX component can't create object: 'OurDLL.clsMyObj'"
The error appears on the line:
Set myObj = CreateObject("OurDLL.clsMyObj")
The script works fine in 32-bit CMD, but not in 64-bit CMD, so I have reason to believe it's an architecture issue. I like to use Cygwin for editing and testing; I'm fine with using two different versions, but I'd like to avoid the hassle of keeping both configured if I can.
So, the question is:
Upvotes: 2
Views: 1052
Reputation: 200453
By default Windows launches the script interpreter that matches the type of the parent process (32-bit interpreter if the parent process is 32-bit, 64-bit interpreter if the parent process is 64-bit). If your Cygwin shell is 64-bit you need to explicitly launch your VBScript in a 32-bit interpreter:
C:\Windows\SysWOW64\cscript.exe //NoLogo "C:\path\to\your.vbs"
C:\Windows\SysWOW64\wscript.exe //NoLogo "C:\path\to\your.vbs"
If you want the call to be portable between 32-bit and 64-bit installations I'd define a launch function like this:
function RunVBS32 {
if [ -f "C:\Windows\SysWOW64\cscript.exe" ]; then
"C:\Windows\SysWOW64\cscript.exe" //NoLogo "$1"
else
"C:\Windows\cscript.exe" //NoLogo "$1"
fi
}
Upvotes: 4
Reputation: 3582
It depends on what you are using and how it's invoked.
I have seen compatibility problems with scripting languages that try to tie into 32 objects (like cygwin 64 python trying to use a 32 bit oracle driver).
As far as command line scripts like vbs, or shell script, it shouldn't make any difference. IOW, if you can execute a command in CMD, you should be able to execute it in Cygwin.
In some cases, I have seen windows will actually offer two different 32/64 commands to do something. In these cases, you have to specify the full path to the executable.
My guesss (I'm not sure) is you may need to specify the full path of the vbs interpreter to be 32 bit.
Upvotes: 0