最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

windows - converting javascript to exe, WScript has not been declared - Stack Overflow

programmeradmin4浏览0评论

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 of WScript.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 the javascript 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 of new ActiveXObject("WScript.Shell");. I also changed all my references of WScript to omgShell 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
Add a ment  | 

2 Answers 2

Reset to default 5

WScript 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.

发布评论

评论列表(0)

  1. 暂无评论