0
votes

This VBS will help me to hide the CMD prompt when calling a batch file. Both files are in the same location.

Here is my VBS code:

CreateObject("Wscript.Shell").Run "b.bat" & Wscript.Arguments.Item(0),0, False

Here is the batch file code:

if [%1]==[] GOTO :EXIT
Echo abc > %1
:EXIT

and I start my command prompt like this:

c:...\Desktop>a.vbs "a.txt"

The error I get says this:

Error: The system cannot find the file specified.

The batch file will create an empty txt file whose name is specified as a parameter.

Appreciate you help. Thanks.

1
can you share more code?npocmaka
I added more code. Thanks for helping and reply.Skeiths Chew

1 Answers

2
votes

Be careful with spaces in your command. This:

CreateObject("Wscript.Shell").Run "b.bat" & Wscript.Arguments.Item(0),0, False

Should be:

CreateObject("Wscript.Shell").Run "b.bat " & Wscript.Arguments.Item(0),0, False