This batch launcher was created so that batch files won't launch a command prompt window... Now that i'm adding more variables to it, it's not working...
I'm launching the VBScript like so;
wscript D:\batchlaunchersyntax.vbs D:\the batch\batch.bat 11 D:\program files\hello world
This will be a repetitive task with only the last 2 variables changing. I would like to launch the batch file passing the number followed by a directory variable.
Can you please help me edit this VBScript in order to do that?
'--------------------8<----------------------
sTitle = "Batch launcher"
Set oArgs = WScript.Arguments
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oShell = CreateObject("WScript.Shell")
If oArgs.Count <> 2 Then
' Will die after 10 seconds if no one is pressing the OK button
oShell.Popup "Error: You need to supply a file path " _
& "as input parameter!", 10, sTitle, vbCritical + vbSystemModal
Wscript.Quit 1
End If
sFilePath = oArgs(0)
sArg = oArgs(1)
If Not oFSO.FileExists(sFilePath) Then
' Will die after 10 seconds if no one is pressing the OK button
oShell.Popup "Error: Batch file not found", _
10, sTitle, vbCritical + vbSystemModal
Wscript.Quit 1
End If
' add quotes around the path in case of spaces
iRC = oShell.Run("""" & sFilePath & """" & sArg, 0, True)
' Return with the same errorlevel as the batch file had
Wscript.Quit iRC
'--------------------8<----------------------
I'm launching the VBScript like so;
wscript D:\batchlaunchersyntax.vbs D:\the batch\batch.bat 11 D:\program files\hello world
This will be a repetitive task with only the last 2 variables changing. I would like to launch the batch file passing the number followed by a directory variable.
Can you please help me edit this VBScript in order to do that?
'--------------------8<----------------------
sTitle = "Batch launcher"
Set oArgs = WScript.Arguments
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oShell = CreateObject("WScript.Shell")
If oArgs.Count <> 2 Then
' Will die after 10 seconds if no one is pressing the OK button
oShell.Popup "Error: You need to supply a file path " _
& "as input parameter!", 10, sTitle, vbCritical + vbSystemModal
Wscript.Quit 1
End If
sFilePath = oArgs(0)
sArg = oArgs(1)
If Not oFSO.FileExists(sFilePath) Then
' Will die after 10 seconds if no one is pressing the OK button
oShell.Popup "Error: Batch file not found", _
10, sTitle, vbCritical + vbSystemModal
Wscript.Quit 1
End If
' add quotes around the path in case of spaces
iRC = oShell.Run("""" & sFilePath & """" & sArg, 0, True)
' Return with the same errorlevel as the batch file had
Wscript.Quit iRC
'--------------------8<----------------------