Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

help with shell.run path

Status
Not open for further replies.

vanvb

Programmer
Feb 7, 2003
255
CA
Can anyone help me out with what is wrong with this:

Code:
function manage(strComputer) 
{
   var Shell = new ActiveXObject("WScript.shell");
   Shell.run("\"C:\\WINDOWS\\system32\\mmc.exe C:\\WINDOWS\\system32\\compmgmt.msc \/computer:" & strComputer & "\"");
}

I can use the function below and it works, but I am having trouble with the escape characters and quotes because the above function is giving me a "system cannot find the file specified" error.

Code:
function manage(strComputer) 
{
   var Shell = new ActiveXObject("WScript.shell");
   Shell.run("c:\\windows\\system32\\notepad.exe");
}
Thanks for the help!
 
I found the problem. It appears that my variable strComputer that I was passing into my function was being interpreted as an integer...not text...so when I made it part of the command it turned the value of the whole line to 0. I concatenated "" to it to turn it into a string before using it and that fixed things.

Code:
var Shell = new ActiveXObject("WScript.shell");
var strCMD = "c:\\windows/system32/mmc.exe";
strCMD += " c:\\windows/system32/compmgmt.msc";
strCMD += " /computer:";
strComputer += "";
strCMD += strComputer;
Shell.Run(strCMD);
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top