Converting javascript to exe, WScript was not declared

We have one javascript

that I would like to compile with exe

.

I am using jsc.exe

for this. However, when I try to compile, I get the following error.

error JS1135: Variable 'WScript' has not been declared

      

Here is the code segment:

var omgShell = WScript.CreateObject( "WScript.Shell" );

      

What is the problem?

thank

+3


source to share


2 answers


WScript is a variable that is not available in the context of jsc.exe. See this post for details .

In your case, just use var omgShell = new ActiveXObject("WScript.Shell");

and replace all references to WScript

byomgShell



or just do var WScript = new ActiveXObject("WScript.Shell");

+5


source


JScript.NET is not the same as WSH. You will need to change your code to use .NET objects instead of WSH objects.



+3


source







All Articles