On Tue, 05 Aug 2003 22:14:51 GMT, Andrew <be********@rogers.com> wrote:
I have written a jscript that is executed when the user logs into the
network. Among other things, I want the script to be able to run an
executable which is stored on the network. Can anyone tell me the proper
syntax for this? I think the line, WshShell.Run, is to be used but
unsure
of how it would be written.
Here's an example of how to use a shell object, in this case to execute a
"net send" and check if the execution was successful:
var oShell = new ActiveXObject("WScript.Shell");
....
var cmd = "%ComSpec% /c net send " + machine + " \"" + msg + "\"";
var windowReturnCode = oShell.Run(cmd, 0, true);
var statusmessage = "Failed to send message\r\n";
switch (windowReturnCode) {
case 0 : statusmessage = "Message successfully sent"; break;
case 2 : statusmessage += "The computer could not be found on the
network."; break;
default : statusmessage += "Error code: " + windowReturnCode;
}
....
Adapt it for your own needs and add a liberal sprinkling of try and
catches. The switch is acting on the return code that the shell received
upon execution of the command.
More details in the Windows Script Host docs that are buried somewhere on
Microsft's MSDN site.
--
Andrew Urquhart
-
http://www.andrewu.co.uk/clj.asp
- FAQ for comp.lang.javascript by Jim Ley at
http://jibbering.com/faq
- Archive at
http://groups.google.com/groups?grou...ang.javascript