Reputation:
I am a C# developer using Visual Studio, but I'm interested in creating some JScript or JQuery programs to run on our Windows machines. There is obviously a learning curve I've got to get over.
I'd like to start by mimicing a VBScript I was presented with not long ago:
Dim wshShell
Set wshShell = CreateObject("WScript.Shell")
wshShell.Run "msiexec.exe /i ""\\CPFS2\Share Files\package.msi"" /l*v ""C:\install.txt""", 1, true
wshShell.Run "C:\install.log"
Can this be done with either JScript or JQuery?
What are good search tool terms to help me locate help on this topic? (JScript, Windows is not producing much)
Upvotes: 0
Views: 1433
Reputation: 95
Check jQuery for admins http://code.google.com/p/jquery-for-admins/
Plus you can use Mongoose + WSH as cgi to show nice HTML report about executing admin tasks.
Upvotes: 1
Reputation: 26086
JScript is just what Microsoft calls its implementation of ECMAScript. ECMAScript is more commonly known as JavaScript, though this is technically improper. jQuery is a JavaScript library designed to make manipulating the DOM easier. While it can be used to some extent outside of a web browser it doesn't make as much sense to do so.
What it sounds like you want to do is run JavaScript scripts locally on a Windows box instead of VBScript scripts. In either case this is done by using the Windows Scripting Host. JavaScript doesn't offer much intrinsic support for I/O but instead relies on the environment in which it is run. In a web browser it primarily intereacts with the DOM but in the WSH it will interact with the same objects that are provided to VBScript.
The equivalent WSH-based JavaScript to yuor VBScript example would be
var wshShell = WScript.CreateObject("WScript.Shell");
wshShell.Run("msiexec.exe /i \"\\\\CPFS2\\Share Files\\package.msi\\\" /l*v \"C:\install.txt\"", 1, true);
wshShell.Run("C:\install.log");
As you can see it's nearly identical, because in both cases you are just scripting the Windows Scripting Host.
There is no "jQuery" equivalent of this, because jQuery is just a set of libraries you can use from JavaScript and nothing being done here would find any of its features useful.
Upvotes: 3
Reputation: 47776
I think this might be the JScript you're looking for.
var shell = new ActiveXObject("WScript.shell");
shell.run("whatever");
I can't test it right now, but even if it works, I would really recommend you look into node.js instead of using JScript.
Upvotes: 2
Reputation: 4273
JQuery is a JavaScript library that helps with manipulation of the structure of web pages, and as such is useless for desktop applications. I think you're confusing the term 'JQuery' (a library) with JavaScript (a scripting language).
If your question is whether you can use JavaScript or JScript (which is Microsofts variety of JavaScript) for Windows scripting, the short version is: yes you can. You can run JScript scripts right from Windows, and you can create Windows PowerShell cmdlets using JScript.NET.
Upvotes: 1