Every time it sent output, it would pop up a message box and wait to be closed to continue execution.
This code prevents this
Add the following Subs and Functions to your scripts
Code: Select all
function cscript
dim scriptName
cscript = false
scriptName = CreateObject("Scripting.FileSystemObject").GetFileName( wscript.FullName )
if scriptName = "cscript.exe" then cscript = True
end function
sub scriptEnd
wscript.Echo "Press [ENTER] to end"
wscript.StdIn.ReadLine
end sub
sub run_in_window
Dim objShell
Set objShell = wscript.CreateObject("wscript.Shell")
objShell.Run "cscript """ & wscript.ScriptFullName & """"
Set objShell = Nothing
wscript.quit
end sub
Code: Select all
Option Explicit
if cscript = false then run_in_window
Code: Select all
scriptEndCut and paste into a .vbs document and double click it!
Code: Select all
Option Explicit
if cscript = false then run_in_window
wscript.echo "We're in a command line!"
scriptEnd
function cscript
dim scriptName
cscript = false
scriptName = CreateObject("Scripting.FileSystemObject").GetFileName( wscript.FullName )
if scriptName = "cscript.exe" then cscript = True
end function
sub scriptEnd
wscript.Echo "Press [ENTER] to end"
wscript.StdIn.ReadLine
end sub
sub run_in_window
Dim objShell
Set objShell = wscript.CreateObject("wscript.Shell")
objShell.Run "cscript """ & wscript.ScriptFullName & """"
Set objShell = Nothing
wscript.quit
end sub