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:
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
}