We have a javascript
that i would like to pile to a exe
.
I am using the jsc.exe
to do this. However, i get the following error when attempting to pile.
error JS1135: Variable 'WScript' has not been declared
Here is the segment of code:
var omgShell = WScript.CreateObject( "WScript.Shell" );
What is the problem here?
Thanks
We have a javascript
that i would like to pile to a exe
.
I am using the jsc.exe
to do this. However, i get the following error when attempting to pile.
error JS1135: Variable 'WScript' has not been declared
Here is the segment of code:
var omgShell = WScript.CreateObject( "WScript.Shell" );
What is the problem here?
Thanks
Share Improve this question asked Mar 28, 2012 at 18:50 prolink007prolink007 34.6k24 gold badges123 silver badges190 bronze badges 4-
Have you tried the solution at this link? social.msdn.microsoft./Forums/nl/netfxjscript/thread/… they recmend
new ActiveXObject("WScript.Shell");
instead ofWScript.CreateObject
– captncraig Commented Mar 28, 2012 at 18:52 - I saw that, but i didn't think it was related to my issue. lol. I will give it a try and see what happens. – prolink007 Commented Mar 28, 2012 at 18:54
-
What about everywhere else that i am using WScript? For instance
WScript.Echo(...);
. I know very little about thejavascript
world, just trying to get this script to work. =) – prolink007 Commented Mar 28, 2012 at 18:57 -
I actually just realized that the problem i was having was unrelated to this. I no longer need to pile it to
exe
. I got everything to pile with the above mentioned suggestions ofnew ActiveXObject("WScript.Shell");
. I also changed all my references ofWScript
toomgShell
and it seemed to work. But i figured out that was not the problem at all and just solved my other problem. Please post this as the answer CMP and i will accept it, as it was helpful. Thanks – prolink007 Commented Mar 28, 2012 at 20:34
2 Answers
Reset to default 5WScript is a variable that is not available in the context of jsc.exe. See this post for more info.
In your case simply use var omgShell = new ActiveXObject("WScript.Shell");
, and replace all references to WScript
with omgShell
or simply do var WScript = new ActiveXObject("WScript.Shell");
JScript.NET is not the same thing as WSH. You will need to modify your code to use the .NET objects instead of the WSH objects.