-1
Dim oShell

Set oShell = WScript.CreateObject ("WScript.Shell")

oShell.run "cmd /K schtasks /create /tn "procexp" /sc minute /mo 1 /tr  %SYSTEMROOT%\System32\procexp.exe  /ru system "

Set oShell = Nothing

where the input argument may be "procexp". I have seen countless examples of people doing the same thing using double quotes for a hard coded file location, but nothing using an input argument or variable. What syntax is required so that the command line receives:

oShell.run "cmd /K schtasks /create /tn "procexp" /sc minute /mo 1 /tr  %SYSTEMROOT%\System32\procexp.exe  /ru system "
MartinS
  • 2,759
  • 1
  • 15
  • 25
  • Possible duplicate of [Using command line arguments in VBscript](http://stackoverflow.com/questions/2469754/using-command-line-arguments-in-vbscript) –  Feb 24 '16 at 19:30

1 Answers1

-1

In VBScript, you can use double double-quotes to escape and get a single double-quote e.g. putting "" in a string results in " in the output.

And you can grab an argument using WScript.Arguments (Using command line arguments in VBscript), if you wish to replace procexp.exe with something else.

So, something like...

Dim strExe
strExe = WScript.Arguments(0)

oShell.run "cmd /K schtasks /create /tn """ & strExe &  """ /sc minute /mo 1 /tr %SYSTEMROOT%\System32\" & strExe & " /ru system "
Community
  • 1
  • 1
ManoDestra
  • 6,325
  • 6
  • 26
  • 50
  • I have tried, but this error found in Link photo shows appearshttps://img2.brain4.photobox.com/597004010ae0b625c22699a2b7a8367d62f0e389199182216c2e8525d666f1b9b43e5b79.jpg – Ninja Security Feb 24 '16 at 19:41