0

I just want to execute a batch file stealthly from vb script. My vb script contains the following lines; but it doesn't work. Any idea what I am missing?

Dim min
Dim WshShell
min = InputBox("Enter the number of mins :")
Set WshShell = CreateObject("WScript.Shell")
WshShell.Run chr(34) & "C:\Users\XYZ\Desktop\test.bat " & min & Chr(34), 0 
Set WshShell = Nothing

2 Answers 2

2

Try this:

Dim min
Dim WshShell
min = InputBox("Enter the number of mins :")
Set WshShell = CreateObject("WScript.Shell")
WshShell.Run """C:\temp\test.bat""" & min
Set WshShell = Nothing

Your problem was that the min parameter should be after the Chr(34).

WshShell.Run chr(34) & "C:\Users\XYZ\Desktop\test.bat " & Chr(34) & min, 0

Sign up to request clarification or add additional context in comments.

Comments

0

I did the following modifications to my code and it is working now.

Dim min
Dim WshShell
min = InputBox("Enter the number of mins :")
Set WshShell = CreateObject("WScript.Shell")
strCommand = "C:\Users\Rabindra\Desktop\test.bat " & min
WshShell.Run strCommand, 0, True
Set WshShell = Nothing

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.