0

I have some already written code as cscript //Nologo "%FILEPATH%\GetSys.vbs" >%PCKANRI%\sysinf.txt.

How do I add one argument to this and pass to GetSys.vbs. I want to pass %PCKANRI%'s value.

I tried -

 cscript //Nologo "%FILEPATH%\GetSys.vbs" >%PCKANRI%\sysinf.txt %PCKANRI% 

and

cscript //Nologo "%FILEPATH%\GetSys.vbs"  %PCKANRI%  >%PCKANRI%\sysinf.txt

However, both don't work.

in GetSys.vbs I have

Dim arg1
arg1 = args.Item(0)
MsgBox arg1

I get empty message nox.

1 Answer 1

1

You must initialize args and deal with missing arguments:

type getsys.vbs
Dim args : Set args = WScript.Arguments
Dim arg1
If 1 <= args.Count Then
   arg1 = args(0)
Else
   arg1 = "No arguments!"
End If
WScript.Echo arg1

cscript getsys.vbs
No arguments!

cscript getsys.vbs argument
argument

And:

Putting the extra argument after the file spec (... >%PCKANRI%\sysinf.txt %PCKANRI%) is wrong

Sorry, my mistake. Putting the argument at the end 'works'. Evidence:

cscript getsys.vbs argument > getsys.txt

type getsys.txt
argument

cscript getsys.vbs > getsys.txt option

type getsys.txt
option
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.