Running a batch process with minimised window

  • Thread starter Thread starter Tim Jol
  • Start date Start date
T

Tim Jol

I have several batch files that run throughout the day at
specific intervals. They keep on popping up the command
screen and disapper after execution. This annoys as we
cannot concentrate on the monitor screen doing some other
tasks. Is there a command that I can insert in the
beginning of each batch files so that the command screen
is minimised while it is in execution?
 
Tim said:
I have several batch files that run throughout the day at
specific intervals. They keep on popping up the command
screen and disapper after execution. This annoys as we
cannot concentrate on the monitor screen doing some other
tasks. Is there a command that I can insert in the
beginning of each batch files so that the command screen
is minimised while it is in execution?
Hi

You can e.g. use a vbscript based batch file launcher for this.

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:

oShell.Run """" & sFilePath & """", 0, False

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
End If

sFilePath = oArgs(0)

If Not oFSO.FileExists(sFilePath) Then
MsgBox "Error: Batch file not found", vbCritical + vbSystemModal, sTitle
Wscript.Quit
End If

' add quotes around the path in case of spaces
oShell.Run """" & sFilePath & """", 0, False

'--------------------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
 
In said:
I have several batch files that run throughout the day at
specific intervals. They keep on popping up the command
screen and disapper after execution. This annoys as we
cannot concentrate on the monitor screen doing some other
tasks. Is there a command that I can insert in the
beginning of each batch files so that the command screen
is minimised while it is in execution?

See the START command. START /?

and the "/min" switch.

start /min "" "FQPtobatch"
 
Ok.. Your way looks a bit complex where as I am looking
something built into the command scripting itself.
Now, what I have done is, after the command window is
open I have modified the Lay-out" section of properties
of the pop-up window to display below the screen and with
height as 0 (Window Position). So whenever the the
program runs it is not visible on the main screen. It is
somewhere below the system tray. If at all I want to view
it, I right click on the active command icon on the
system tray and maximise. That's it !!!
 
Mark said:
In microsoft.public.win2000.cmdprompt.admin Tim Jol wrote:




See the START command. START /?

and the "/min" switch.

start /min "" "FQPtobatch"
Wouldn't you have to open a non-minimized CMD Window to execute start if
you were using start to call a CMD Window?

--
-=[PsyB]=-

Greater in battle than the man who would conquer a thousand-thousand men
is he who would conquer just one - *himself*.

--Dhammapada--
 
In said:
Wouldn't you have to open a non-minimized CMD Window to execute
start if you were using start to call a CMD Window?

Technically yes. But the window is just a brief flash.
Shortcut Target:
%windir%\system32\CMD.EXE /c START /min "" "c:\temp\say.cmd

And if you also set the shortcut to open minimized it's nearly
distraction-free for the first CMD instance and the second is minimized
for it's duration. Of course if the shortcut is to the batchfile, just
set it to open minimized.

OP I believe was using Task Scheduler rather than an shortcut though.
 
There is also the 'Run' option on the 'Shortcut' tab of the 'Properties'
dialog which can be used to set the shortcut to start in a 'Minimized'
window, regardless of the layout. Thus you can simply 'Restore' the command
window, if you need to.

Tom Lavedas
===========
 
This doesn't work. I have created a shortcut for each of
my .BAT file and call these shortcuts from the scheduler.
When it is executing the CMD windows pops up normally.
Whereas if I double click the shortcut, the CMD window is
not seen and only can be seen active on the system tray.
 
Interesting. I didn't know that. Hadn't tried it as a scheduled task.

Tom Lavedas
===========
 
Well, it is working this way...(As suggested by other
gentlemen in this thread)

I created a batchfile as SCHED-ACTUAL.BAT containing one
line "START /MIN C:\TEST\ACTUAL.BAT". The file ACTUAL.BAT
contains my actual tasks. I have put the SCHED-ACTUAL.BAT
in the scheduler. Thats it!

Maybe use the following in the scheduler and then a 2nd batch wouldn't
be needed.

"cmd /c START /MIN C:\TEST\ACTUAL.BAT"

Clay Calvert
(e-mail address removed)
Replace "W" with "L"
 
Sounds good!

Thanks.
-----Original Message-----


Maybe use the following in the scheduler and then a 2nd batch wouldn't
be needed.

"cmd /c START /MIN C:\TEST\ACTUAL.BAT"


Clay Calvert
(e-mail address removed)
Replace "W" with "L"
.
 
Back
Top