Forum Discussion

hc_vinod's avatar
hc_vinod
Occasional Contributor
10 years ago

passing arguments as parameter to command prompt

Hi , 

 

I need to open a command prompt from my script and need to enter some comands , and these commands i need to pass as a parameter 

 

Something like : i need to open CMD prompt and enter ping 192.168.2.100,  where my IP will be stored in  variable 

 

IP= "192.168.2.100"

i tried the following  sys.oleObject("wscript.shell").Exec (cmd/c ping @IP) but not working 

  • Try

     

      var cmd = "ping 127.0.0.1";
      var oShell = Sys.OleObject("WScript.Shell");
      var ret = oShell.run("cmd /C " + cmd, 1, true);
      Log.Message("ret = " + ret);

    See Microsoft docs for more info: Run Method

     

     

  • Try

     

      var cmd = "ping 127.0.0.1";
      var oShell = Sys.OleObject("WScript.Shell");
      var ret = oShell.run("cmd /C " + cmd, 1, true);
      Log.Message("ret = " + ret);

    See Microsoft docs for more info: Run Method

     

     

    • hc_vinod's avatar
      hc_vinod
      Occasional Contributor

      Thanks

       

      I am able to pass argument