Arguments with Invisible.vbs

Microsoft Windows
Post Reply
User avatar
MigrationUser
Posts: 336
Joined: 2021-Jul-12, 1:37 pm
Been thanked: 2 times
Contact:

Arguments with Invisible.vbs

Post 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
Post Reply