I have a couple of .WSF files that work properly under Win32.
These files reference Msxml2.DOMDocument.4.0 object. Under Win64
WSH refuses to run the script with the error:
Windows Script Host: Cannot find the type library for this
reference : Msxml2.DOMDocument.4.0
When I run a file with 32-bit WSH host explicitly (via
%WINDIR%\SysWOW64\Cscript.exe), then everything works fine.
Here's the example .WSF file:
------- XmlTest.wsf -------
<job id="main">
<?job debug="true"?>
<reference object="Msxml2.DOMDocument.4.0" />
<object id="xmlDoc" progid="Msxml2.DOMDocument.4.0" />
<script language="JScript">
</script>
</job>
---------------------------
I don't want to specify 32-bit explicitly every time. What should
I do in order to run this script under Win64?
Thanks in advance
Alex
OK, I found that MSXML 4.0 does not exist under 64-bit Windows. I
need to move to MSXML 6.0 or fall back to MSXML 3.0, which exist
in both flavours of Windows.
Alex
I want to run it regardless of the Windows version. These scripts
may be used by any member of our team on a variety of PC boxes:
from 32-bit XP to 64-bit 2008 Server. That's why it is important
for me to make the execution transparent for a user.
Alex
I don't think you have much choice.
1) You can set all PCs to default to wscript (or cscript)
32-bit. (Then you can set them back in 2018 when
64-bit becomes relevant. :)
2) You can write the scripts to adapt to the system.
That means that on 64-bit you'll never be able to use
any objects except those Microsoft objects that come
in 64-bit.
I don't know offhand how you identify 64-bit via
script. But if you use method #2 you'd have to do
that, essentially having dual scripts that fork to separate
routines once the system version has been ascertained.
I am perfectly fine with this. My question was not about any
ActiveX object in general, but specifically about MSXML object.
MSXML 6.0 is available on all version of Windows used in our team.
Thanks
Alex
Have you tried not explicitly specifying the version and letting windows
choose the active version?
<reference object="Msxml2.DOMDocument" />
<object id="xmlDoc" progid="Msxml2.DOMDocument" />
The problem is that versionless declaration defaults to MSXML 3.0.
For my script I need at least version 4.0 - some of the features
I use are available only in version 4.0 and higher.
Thanks
Alex
You might consider trapping the error & then checking the variable type.
If the object is successfully instantiated, you should have an 'object'
variable type. If you don't, try the other version. I write in VBScript, so
I am not sure how to do it in JavaScript.
Also, I don't have a 64-bit version of Windows, but my 32-bit version of
XP has the 6.0 version of MSXML installed. I don't remember explicitly doing
this, so I assume it go installed with a Service Pack or security patch. If
this is true of your workstations, you could try the 6.0 on the 32-bit
versions of Windows to see if it works as expected.
This is exactly what I did as I described in my other post. Now my
script uses MSXML 6.0 by default. This version of MSXML is
available on all our workstations. I comes with many MS products
by default.
Thanks
Alex