problem using COM object in VBScript from v16 x64 TCC but not from v15 32-bit TCC

Jun 3, 2008
137
3
Temecula, CA
I've got a home-grown COM component, PEIVersion.dll, that works fine from VB6 (yes, VB6) programs. It also works fine in a VBScript, Version.vbc, when I execute it from a 32-bit installation of TCC 15.01.52 on Windows 7.

Code:
->type c:\Utils\version.vbc
Dim sFile, sVersion, ArgObj, StdOut, i, fso, version
Set ArgObj = WScript.Arguments
Set StdOut = WScript.StdOut
Set fso = CreateObject("Scripting.FileSystemObject")
Set version = CreateObject("PEIVersionDLL.PEIVersion")
For i = 0 To ArgObj.Count - 1
  sFile = ArgObj.Item(i)
  sVersion = GetVersion(sFile)
  WScript.Echo sFile & " is version " & sVersion
Next
Set fso = Nothing
Set version = Nothing
WScript.Quit (0)
Function GetVersion(PathSpec)
  Dim temp
  If fso.FileExists(PathSpec) Then
    temp = version.GetPEIVersion(PathSpec)
    If Len(temp) Then
      GetVersion = temp
    Else
      GetVersion = "*** No version information available. ***"
    End If
  Else
    GetVersion = "*** File not found. ***"
  End If
End Function

Here is the execution under TCC 15, 32-bit:

Code:
->ver
TCC 15.01.52 Windows 7 [Version 6.1.7601]
->assoc .vbc
.VBC=VBCFile

->ftype vbcfile
vbcfile="C:\Windows\System32\CScript.exe" "%1" %*
 
->which version
version is an executable extension : C:\Windows\system32\cscript.exe /nologo c:\Utils\Version.vbc
 
->version c:\Emacs\bin\emacs.exe
c:\Emacs\bin\emacs.exe is version 24.3.0.0

When I run the same script on the same Windows 7 64-bit machine, but under TCC v16 x64, the script reports that it can't create the PEIVersionDLL.PEIVersion object.

Code:
->ver
TCC 16.00.36 x64 Windows 7 [Version 6.1.7601]

->assoc .vbc
.VBC=VBCFile

->ftype vbcfile
vbcfile="C:\Windows\System32\CScript.exe" "%1" %*
->which version
version is an executable extension : C:\Windows\system32\cscript.exe /nologo c:\Utils\Version.vbc

->version c:\Emacs\bin\emacs.exe
C:\Utils\Version.vbc(6, 1) Microsoft VBScript runtime error: ActiveX component can't create object: 'PEIVersionDLL.PEIVersion'

Is there something about the COM registration that is different for the 64-bit TCC versus the 32-bit TCC, or is it something else? Anyone have any ideas on how I might fix or even troubleshoot this?
 

samintz

Scott Mintz
May 20, 2008
1,555
26
Solon, OH, USA
On my PC, Win7 Ultimate x64 SP1, I have the following instances of CSCRIPT.EXE:
Code:
C:\Windows\SysWOW64\cscript.exe
C:\Windows\System32\cscript.exe
C:\Windows\winsxs\amd64_microsoft-windows-scripting_31bf3856ad364e35_6.1.7600.16385_none_a45d44bd1a0af822\cscript.exe
C:\Windows\winsxs\amd64_microsoft-windows-scripting_31bf3856ad364e35_6.1.7601.18283_none_a6418c4d17334828\cscript.exe
C:\Windows\winsxs\amd64_microsoft-windows-scripting_31bf3856ad364e35_6.1.7601.22480_none_a6c82a2030539914\cscript.exe
C:\Windows\winsxs\wow64_microsoft-windows-scripting_31bf3856ad364e35_6.1.7601.18283_none_b096369f4b940a23\cscript.exe
C:\Windows\winsxs\wow64_microsoft-windows-scripting_31bf3856ad364e35_6.1.7601.22480_none_b11cd47264b45b0f\cscript.exe
That tells me there are both 32-bit and 64-bit versions of cscript.exe. Can 64-bit VBScript interop with 32 bit COM objects?

Try invoking the 32-bit cscript directly by calling the version in the SysWOW64 directory.

-Scott
 
Jun 3, 2008
137
3
Temecula, CA
Try invoking the 32-bit cscript directly by calling the version in the SysWOW64 directory.

Well, it works now, but it doesn't work. Let me demonstrate.

I typed in the new FTYPE command to reset it to use the SysWOW64 version of cscript.exe for the .vbc file extension, which uses FTYPE of VBCFile. If I query FTYPE for all entries (and then grep just for the VBCFile entry, it looks proper. But if I just use the FTYPE VBCFile command, it says it will use the System32 version. Huh???

Code:
->ftype vbcfile
vbcfile="C:\Windows\System32\CScript.exe" "%1" %*
 
->ftype | grep -i vbcfile
(standard input):VBCFile="C:\Windows\SysWOW64\cscript.exe" "%1" %*

What gives?

Well, if I invoke cscript.exe from the SysWOW64 directory, then version.vbc works.

Code:
->c:\windows\SysWOW64\cscript.exe /nologo c:\Utils\Version.vbc c:\Emacs\bin\emacs.exe
c:\Emacs\bin\emacs.exe is version 24.3.0.0

First, what's going on here, and second, what steps do I need to take to force .vbc files to use the SysWOW64 version of cscript.exe?
 
Jun 3, 2008
137
3
Temecula, CA
Well, for the moment I have a workaround, but it's not good enough for long-term because it's slow. I have the old TCC 32-bit installed, so I just use that TCC /c to execute it:

Code:
->alias version
iff %_x64 = 1 then %+ "c:\Program Files (x86)\JPSoft\TCMD\tcc.exe" /c Version %$ %+ else %+ Version.vbc %$ %+ endiff
 

Similar threads