Page 1 of 1

Arguments with Invisible.vbs

Posted: 2021-Jul-24, 11:01 pm
by MigrationUser
13 Sep 2017 21:04
krasoco


Invisible.vbs (ss64.com/vb/run.html)

This one line VBScript can be used to run a command in an invisible window:

Code: Select all

CreateObject("Wscript.Shell").Run """" & WScript.Arguments(0) & """", 0, False

    ' An example running 'Demo.cmd' with invisible.vbs   
   

wscript.exe "invisible.vbs" "demo.cmd" //nologo
Can I use arguments on demo.cmd (demo.cmd arg1)?

----------------------------

#2 15 Sep 2017 16:38
Pyprohly


Yes, but not with that VBS script.

By using the following code for Invisible.vbs,

Code: Select all

Dim Args()
ReDim Args(WScript.Arguments.Count - 1)

For i = 0 To WScript.Arguments.Count - 1
	Args(i) = """" & WScript.Arguments(i) & """"
Next

CreateObject("WScript.Shell").Run Join(Args), 0, False
You may pass arguments to “demo.cmd” like so:

Code: Select all

wscript.exe //nologo "invisible.vbs" "demo.cmd" arg1 arg2...
Last edited by Pyprohly (17 Sep 2017 08:33)

----------------------------

#3 16 Sep 2017 20:33
krasoco


Thank you!

original thread: https://ss64.org/oldforum/viewtopic.php?id=2240