Have you ever tried to run some existing QTP scripts on a Windows 64 bit OS only to be frustrated by odd errors?
Recently, I was helping a friend get his machine setup to run some scripts that I had created for him.
Everything ran fine on my 32bit OS machine, but when I attempted to run the same script on his machine, numerous errors began popping up almost immediately.
Following are the two 64bit specific issues I have seen, as well as the fix for them:
ODBC – The specified DSN contains an architecture mismatch Error
The first test I had issues with needed an ODBC System DSN setup on the test machine in order for the script to work. No problem. I went into Programs>Administrative Tools>Data Source (ODBC) and setup a DSN like I normally would. I also Ran the ‘Test Data Source’ option successfully.
Okay cool. So then I go to run the script, and crash! The script throws this Run Error:
“[Microsoft][ODBC Driver Manager] The specified DSN contains an architecture mismatch between the Driver and Application”
After some head scratching, I finally figured out that the default ODBC Data Source Administrator is the 64bit version — not 32bit. DUH!
How to resolve QTP 64bit ODBC issue
To resolve the issue, all you need to do is evoke the 32 bit ODBC Data Source Administrator instead. The quickest way to do this is enter: C:\Windows\SysWOW64\odbcad32.exe in the Start>Run menu.
This will bring up the correct ODBC setup. You can then enter your System DSN info, and should be good to go.
ActiveX component can’t create object error
The other issue I had was with a script that used Excel. Whenever I called an Excel function in my .vbs function library, I’d get this error:
“ActiveX component can’t create object: ‘Excel.Application’“
Once again, this worked fine on all my 32bit machines, but crashed (with the same error) on all my 64bit OS machines.
When running VBscript on a 64bit OS, the default Windows Scripting host is the 64bit, and it expected to find a 64bit DLL and EXE to be started. And because QTP doesn’t have a 64bit entry point, it chokes.
How to fix the 64bit ActiveX error
Just like the ODBC issue we saw earlier, we also need to explicitly tell QTP to use the 32bit version of the scripting host. To do this, simply go to a command line and type in the path to the 32bit scripting host.
c:\windows\SysWOW64\cscript.exe followed by the name of your vbs file in quotes
Rerun your script. You should no longer see the Active X error.
Hope this helps. Happy 64bit Testing!