#1 13 Sep 2017 21:04

krasoco
Member
Registered: 13 Sep 2017
Posts: 2

Arguments with Invisible.vbs

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

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

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)?

Offline

#2 15 Sep 2017 16:38

Pyprohly
Member
Registered: 26 Nov 2014
Posts: 10

Re: Arguments with Invisible.vbs

Yes, but not with that VBS script.

By using the following code for Invisible.vbs,

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:

wscript.exe //nologo "invisible.vbs" "demo.cmd" arg1 arg2...

Last edited by Pyprohly (17 Sep 2017 08:33)

Offline

#3 16 Sep 2017 20:33

krasoco
Member
Registered: 13 Sep 2017
Posts: 2

Re: Arguments with Invisible.vbs

Thank you!

Offline

Board footer

Powered by FluxBB