Reputation: 161
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.
Upvotes: 0
Views: 4448
Reputation: 1418
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
Upvotes: 2