Windows Script Host JScript Scripting Engine Difficulty

0

I am attempting to run a JScript script using Windows Script Host 5.8 on a 32-bit Windows 7 PC. This script is part of a larger build effort for an open source software project, where an ActiveXObject is being created as part of the script. This has failed to run, but I suspect that the specific script is not at fault, but rather my local Windows Scripting Host (WSH) setup.

I have inferred this based on the following 'bare bones' tests that I have run with a one line test script:

I prepare a script using Notepad which is saved as 'test.js' and contains the following line:

var strLit = "This is a string literal.";

I then execute the above script using the following command:

cscript /e:jscript test.js

This seems to run successfully, of course returning no output, but critically no error message.

I then change the script to contain just the following line:

print("Hello World!");

When run with the same command as above, the following error message is received:

Microsoft JScript runtime error: Object expected

I then change the script to contain just the following line:

var fso = new ActiveXObject("Scripting.FileSystemObject");

When run with the same command as above, the following error message is received:

Microsoft JScript runtime error: Automation server can't create object

It is this third version of the script that contains the line failing in the open source software script mentioned above. However, based on the creation of a string variable script succeeding, I would infer that WSH is to some extent functioning. However, the fact that the 'hello world' script has failed, as well as the failure of the ActiveXObject would indicate that WSH with the JScript engine may not be correctly set-up on my computer or otherwise functioning.

I would also infer that this likely has nothing to do with Internet Explorer security levels due to this script being run from the command line with no link to Internet Explorer.

I have done the following to try to resolve this problem:

  • Ensured that Windows associates files with extension '.js' with WSH, although by using the '/e:' switch when calling the script as above, this is not an issue anyway.

  • Re-registered scripting components on my computer using an administrator elevated command prompt with the following commands:

    regsvr32 %systemroot%\system32\vbscript.dll regsvr32 %systemroot%\system32\jscript.dll regsvr32 %systemroot%\system32\dispex.dll regsvr32 %systemroot%\system32\scrobj.dll regsvr32 %systemroot%\system32\scrrun.dll regsvr32 %systemroot%\system32\wshext.dll regsvr32 %systemroot%\system32\wshom.ocx

All of the above commands work successfully, except for the last two, where the following errors are received:

The module "C:\Windows\system32\wshext.dll" was loaded but the call to DllRegisterServer failed with error code 0x80040201

The module "C:\Windows\system32\wshom.ocx" was loaded but the call to DllRegisterServer failed with error code 0x80040201

  • Attemped to run the script with my virus protection (F-Secure) completely disabled and there being no internet connection.

I would infer the following from the tests above:

  • Script one: This is a simple script declaring and initializing a variable and doing nothing else, meaning that it is no surprise that it should run and perhaps confirms that the JScript engine is at least present and working fundamentally.
  • Script two: This is again a simple script but that may make use of additional functionality (I. e. 'print').
  • Script three: This is a simple script, but seeks to create an object of a specific type, by means of recourse to an application (identified as 'Scripting') to achieve this. This 'Scripting' application is supplied as a parameter when creating a new ActiveXObject which in the Microsoft JScript reference is identified as a 'servername'. Generically, the 'servername' is defined by the Microsoft JScript reference in this context as being 'the name of the application providing the object'. I note that the error message for script three makes reference to an 'automation server' and therefore wonder if there is a link here.

Would anybody have any ideas as to what may be the problem here, specifically with script three? The error message in script three above has been widely discussed online in the context of Internet Explorer security levels, but due to this being a script run on the command line, I cannot see how this solution would relate this problem.

Any ideas would be much appreciated.

Thanks

Jason

windows
jscript
wsh
asked on Stack Overflow Dec 29, 2016 by Jason Marshall

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0