Archived from groups: microsoft.public.win2000.general (
More info?)
flahmeshess wrote:
> I have written a batch and I want to schedule it to run every half
> hour. However, I can't seem to get it to run minimised. It keeps
> poping up a black windows (the command prompt style).
>
> Can this be done ?
>
> Thanks.
>
Hi,
Something like this maybe in the scheduled task:
cmd.exe /c START /MIN C:\TEST\ACTUAL.BAT
Or you can e.g. use a vbscript based batch file launcher for this, this
way you can hide the batch file completely.
Run it like this:
wscript.exe "C:\My Scripts\BatchLaunher.vbs" "C:\My Scripts\tst.bat"
In the code below, it is the 0 in this line that hides the
batch file execution:
iRC = oShell.Run("""" & sFilePath & """", 0, True)
If you want to run it visible, but minimized, change the 0 to 7.
Content of BatchLaunher.vbs:
'--------------------8<----------------------
sTitle = "Batch launcher"
Set oArgs = WScript.Arguments
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oShell = CreateObject("WScript.Shell")
If oArgs.Count <> 1 Then
MsgBox "Error: You need to supply a file path " _
& "as input parameter!", vbCritical + vbSystemModal, sTitle
Wscript.Quit 1
End If
sFilePath = oArgs(0)
If Not oFSO.FileExists(sFilePath) Then
MsgBox "Error: Batch file not found", vbCritical + vbSystemModal, sTitle
Wscript.Quit 1
End If
' add quotes around the path in case of spaces
iRC = oShell.Run("""" & sFilePath & """", 0, True)
' Return with the same errorlevel as the batch file had
Wscript.Quit iRC
'--------------------8<----------------------
WSH 5.6 documentation (local help file) can be downloaded
from here if you haven't got it already:
http://msdn.microsoft.com/downloads/list/webdev.asp
--
torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway
Administration scripting examples and an ONLINE version of
the 1328 page Scripting Guide:
http://www.microsoft.com/technet/scriptcenter/default.mspx