PC Review


Reply
Thread Tools Rating: Thread Rating: 6 votes, 5.00 average.

Running .bat files minimized from scheduler

 
 
Ken Levy
Guest
Posts: n/a
 
      7th Sep 2005
I have some .bat files which are run from the Windows Scheduled Task list.

The problem is that a DOS box pops up whenever these tasks are executed.
I'd like to run the tasks minimized so that the normal windows desktop
doesn't get covered up by these tasks.

There is no properties for the .bat file that I can set to run the task
minimized. I tried creating a shortcut for the .bat file which does have a
property tab with a setting for the startup mode. Every time I try to
change my Scheduled task to use the shortcut (.lnk) file, though, it
switches the filename back to the object of the .lnk file (the original
batch file) rather than keeping the .lnk file in the target filename field.

Can anyone suggest a way for me to hide (or at least minimize) these started
tasks?

Thanks in advance for any assistance. Please posts replies to the
newsgroup.

Ken


 
Reply With Quote
 
 
 
 
David H. Lipman
Guest
Posts: n/a
 
      7th Sep 2005
From: "Ken Levy" <(E-Mail Removed)>

| I have some .bat files which are run from the Windows Scheduled Task list.
|
| The problem is that a DOS box pops up whenever these tasks are executed.
| I'd like to run the tasks minimized so that the normal windows desktop
| doesn't get covered up by these tasks.
|
| There is no properties for the .bat file that I can set to run the task
| minimized. I tried creating a shortcut for the .bat file which does have a
| property tab with a setting for the startup mode. Every time I try to
| change my Scheduled task to use the shortcut (.lnk) file, though, it
| switches the filename back to the object of the .lnk file (the original
| batch file) rather than keeping the .lnk file in the target filename field.
|
| Can anyone suggest a way for me to hide (or at least minimize) these started
| tasks?
|
| Thanks in advance for any assistance. Please posts replies to the
| newsgroup.
|
| Ken
|

Execute;

start /min filename.bat

as the task in .JOB file.

--
Dave
http://www.claymania.com/removal-trojan-adware.html
http://www.ik-cs.com/got-a-virus.htm


 
Reply With Quote
 
 
 
 
Pegasus \(MVP\)
Guest
Posts: n/a
 
      7th Sep 2005

"Ken Levy" <(E-Mail Removed)> wrote in message
news:%23uSVeZ%(E-Mail Removed)...
> I have some .bat files which are run from the Windows Scheduled Task list.
>
> The problem is that a DOS box pops up whenever these tasks are executed.
> I'd like to run the tasks minimized so that the normal windows desktop
> doesn't get covered up by these tasks.
>
> There is no properties for the .bat file that I can set to run the task
> minimized. I tried creating a shortcut for the .bat file which does have

a
> property tab with a setting for the startup mode. Every time I try to
> change my Scheduled task to use the shortcut (.lnk) file, though, it
> switches the filename back to the object of the .lnk file (the original
> batch file) rather than keeping the .lnk file in the target filename

field.
>
> Can anyone suggest a way for me to hide (or at least minimize) these

started
> tasks?
>
> Thanks in advance for any assistance. Please posts replies to the
> newsgroup.
>
> Ken
>
>


When creating the scheduled task, specify an account other
than your own.


 
Reply With Quote
 
Ken Levy
Guest
Posts: n/a
 
      7th Sep 2005
Dave:

Thanks for the quick response. I read the doc for the start command and it
certainly sounds like what I need.

I tried changing the Run command in the Scheduled task to:

start /min C:\Scripts\Destination_inbound_ftp5.bat

but the job did not start. Here is what is in the log . . .

"Destination_inbound_ftp5.job" (start) 9/7/2005 4:45:00 PM ** ERROR **
Unable to start task.
The specific error is:
0x80070002: The system cannot find the file specified.

If I remove the "start /min ", the job runs just fine, so the batch file
path and filename are correct. Does the start command have to be fully
qualified with a path? I did a search for it in the WINNT directory and
could not find it. Is it an internal command?

Any other suggestions? This one has me stumped . . .
Thanks.

Ken



"David H. Lipman" <DLipman~nospam~@Verizon.Net> wrote in message
news:%23QM$Ne%(E-Mail Removed)...
> From: "Ken Levy" <(E-Mail Removed)>
>
> | I have some .bat files which are run from the Windows Scheduled Task
> list.
> |
> | The problem is that a DOS box pops up whenever these tasks are executed.
> | I'd like to run the tasks minimized so that the normal windows desktop
> | doesn't get covered up by these tasks.
> |
> | There is no properties for the .bat file that I can set to run the task
> | minimized. I tried creating a shortcut for the .bat file which does
> have a
> | property tab with a setting for the startup mode. Every time I try to
> | change my Scheduled task to use the shortcut (.lnk) file, though, it
> | switches the filename back to the object of the .lnk file (the original
> | batch file) rather than keeping the .lnk file in the target filename
> field.
> |
> | Can anyone suggest a way for me to hide (or at least minimize) these
> started
> | tasks?
> |
> | Thanks in advance for any assistance. Please posts replies to the
> | newsgroup.
> |
> | Ken
> |
>
> Execute;
>
> start /min filename.bat
>
> as the task in .JOB file.
>
> --
> Dave
> http://www.claymania.com/removal-trojan-adware.html
> http://www.ik-cs.com/got-a-virus.htm
>
>



 
Reply With Quote
 
David H. Lipman
Guest
Posts: n/a
 
      7th Sep 2005
From: "Ken Levy" <(E-Mail Removed)>

| Dave:
|
| Thanks for the quick response. I read the doc for the start command and it
| certainly sounds like what I need.
|
| I tried changing the Run command in the Scheduled task to:
|
| start /min C:\Scripts\Destination_inbound_ftp5.bat
|
| but the job did not start. Here is what is in the log . . .
|
| "Destination_inbound_ftp5.job" (start) 9/7/2005 4:45:00 PM ** ERROR **
| Unable to start task.
| The specific error is:
| 0x80070002: The system cannot find the file specified.
|
| If I remove the "start /min ", the job runs just fine, so the batch file
| path and filename are correct. Does the start command have to be fully
| qualified with a path? I did a search for it in the WINNT directory and
| could not find it. Is it an internal command?
|
| Any other suggestions? This one has me stumped . . .
| Thanks.
|
| Ken

Change that to:

%comspec% /c start /min "C:\Scripts\Destination_inbound_ftp5.bat"

You have a long file name and it needs to be in quotes. Note that in my example I used a
BAT file using 8.3 naming convention so no quotes were needed. However, I made the mistake
in not using '%comspec% /c' in my example as this is needed for Start to be used as Start
is an internal command for both COMMAND.COM and CMD.EXE.

--
Dave
http://www.claymania.com/removal-trojan-adware.html
http://www.ik-cs.com/got-a-virus.htm


 
Reply With Quote
 
Pegasus \(MVP\)
Guest
Posts: n/a
 
      7th Sep 2005
Try this instead:

start /b /min "My Scheduled Task" "C:\Scripts\Destination_inbound_ftp5.bat"


"Ken Levy" <(E-Mail Removed)> wrote in message
news:%23FsYaa$(E-Mail Removed)...
> Dave:
>
> Thanks for the quick response. I read the doc for the start command and

it
> certainly sounds like what I need.
>
> I tried changing the Run command in the Scheduled task to:
>
> start /min C:\Scripts\Destination_inbound_ftp5.bat
>
> but the job did not start. Here is what is in the log . . .
>
> "Destination_inbound_ftp5.job" (start) 9/7/2005 4:45:00 PM ** ERROR **
> Unable to start task.
> The specific error is:
> 0x80070002: The system cannot find the file specified.
>
> If I remove the "start /min ", the job runs just fine, so the batch file
> path and filename are correct. Does the start command have to be fully
> qualified with a path? I did a search for it in the WINNT directory and
> could not find it. Is it an internal command?
>
> Any other suggestions? This one has me stumped . . .
> Thanks.
>
> Ken
>
>
>
> "David H. Lipman" <DLipman~nospam~@Verizon.Net> wrote in message
> news:%23QM$Ne%(E-Mail Removed)...
> > From: "Ken Levy" <(E-Mail Removed)>
> >
> > | I have some .bat files which are run from the Windows Scheduled Task
> > list.
> > |
> > | The problem is that a DOS box pops up whenever these tasks are

executed.
> > | I'd like to run the tasks minimized so that the normal windows desktop
> > | doesn't get covered up by these tasks.
> > |
> > | There is no properties for the .bat file that I can set to run the

task
> > | minimized. I tried creating a shortcut for the .bat file which does
> > have a
> > | property tab with a setting for the startup mode. Every time I try to
> > | change my Scheduled task to use the shortcut (.lnk) file, though, it
> > | switches the filename back to the object of the .lnk file (the

original
> > | batch file) rather than keeping the .lnk file in the target filename
> > field.
> > |
> > | Can anyone suggest a way for me to hide (or at least minimize) these
> > started
> > | tasks?
> > |
> > | Thanks in advance for any assistance. Please posts replies to the
> > | newsgroup.
> > |
> > | Ken
> > |
> >
> > Execute;
> >
> > start /min filename.bat
> >
> > as the task in .JOB file.
> >
> > --
> > Dave
> > http://www.claymania.com/removal-trojan-adware.html
> > http://www.ik-cs.com/got-a-virus.htm
> >
> >

>
>



 
Reply With Quote
 
Torgeir Bakken \(MVP\)
Guest
Posts: n/a
 
      8th Sep 2005
Ken Levy wrote:

> I have some .bat files which are run from the Windows Scheduled Task list.
>
> The problem is that a DOS box pops up whenever these tasks are executed.
> I'd like to run the tasks minimized so that the normal windows desktop
> doesn't get covered up by these tasks.
>
> There is no properties for the .bat file that I can set to run the task
> minimized. I tried creating a shortcut for the .bat file which does have a
> property tab with a setting for the startup mode. Every time I try to
> change my Scheduled task to use the shortcut (.lnk) file, though, it
> switches the filename back to the object of the .lnk file (the original
> batch file) rather than keeping the .lnk file in the target filename field.
>
> Can anyone suggest a way for me to hide (or at least minimize) these started
> tasks?

Hi,


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\BatchLauncher.vbs" "C:\My Scripts\tst.bat"

(BatchLauncher.vbs is the VBScript, tst.bat is your batch file)

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 BatchLauncher.vbs:


'--------------------8<----------------------
sTitle = "Batch launcher"

Set oArgs = WScript.Arguments
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oShell = CreateObject("WScript.Shell")

If oArgs.Count <> 1 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)

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 & """", 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/scr...r/default.mspx
 
Reply With Quote
 
Ken Levy
Guest
Posts: n/a
 
      8th Sep 2005
Thanks Torgeir, that did exactly what I wanted. I tried the variations of
the "start" command that others provided, but they all left the DOS box from
the "cmd" execution hanging at the prompt. I tried coding an exit statement
in the batch file, but I believe that only flushes the secondary command
processer the "start" spawns. I tried some of the other start command
parameters, but none of them would close the original cmd box. Your
technique works great though, so thanks once again.

Ken




"Torgeir Bakken (MVP)" <Torgeir.Bakken-(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Ken Levy wrote:
>
>> I have some .bat files which are run from the Windows Scheduled Task
>> list.
>>
>> The problem is that a DOS box pops up whenever these tasks are executed.
>> I'd like to run the tasks minimized so that the normal windows desktop
>> doesn't get covered up by these tasks.
>>
>> There is no properties for the .bat file that I can set to run the task
>> minimized. I tried creating a shortcut for the .bat file which does have
>> a property tab with a setting for the startup mode. Every time I try to
>> change my Scheduled task to use the shortcut (.lnk) file, though, it
>> switches the filename back to the object of the .lnk file (the original
>> batch file) rather than keeping the .lnk file in the target filename
>> field.
>>
>> Can anyone suggest a way for me to hide (or at least minimize) these
>> started tasks?

> Hi,
>
>
> 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\BatchLauncher.vbs" "C:\My Scripts\tst.bat"
>
> (BatchLauncher.vbs is the VBScript, tst.bat is your batch file)
>
> 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 BatchLauncher.vbs:
>
>
> '--------------------8<----------------------
> sTitle = "Batch launcher"
>
> Set oArgs = WScript.Arguments
> Set oFSO = CreateObject("Scripting.FileSystemObject")
> Set oShell = CreateObject("WScript.Shell")
>
> If oArgs.Count <> 1 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)
>
> 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 & """", 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/scr...r/default.mspx



 
Reply With Quote
 
New Member
Join Date: Sep 2008
Location: Whitehorse, Yukon,Canada
Posts: 1
 
      7th Sep 2008
Insert cmd /C start /min before the program target in the Windows Scheduler job properties.

Add @Exit to the end of the batch file to get the DOS window to close.
 
Reply With Quote
 
New Member
Join Date: Feb 2012
Posts: 2
 
      20th Apr 2012
I keep re-googling this thread so decided to post a short summary for me & others :)

prequisite: all your batch files have an exit-command to fnish the actions off. If you do not exit, you will end with a command prompt blinking.

This is what I keep using:
%comspec% /c start /min "C:\Scripts\Destination_inbound_ftp5.bat"

When you save this in the properties, you will get a follow-up dialogue asking you if you ment all this to be parameters or not. Answer NO and the task will be saved as you would expect.

Thank you David Lipman, Sept 7th 2005 :)

Peace!

Devvie


~~~ (E-Mail Removed) ~~~

Cuisvis hominis est errare, nullius nisi insipientis in errore persevare
——
All spelling mistakes are my own and may only be distributed under the GNU General Public License! – (© 95-1 by Coredump; 2-012 by DevNullius)

Last edited by devnullius; 20th Apr 2012 at 11:09 AM.. Reason: that's between me & the editor ;pp
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Minimized document won't stay minimized. =?Utf-8?B?dGhlIG1pbmltaXplcg==?= Microsoft Word Document Management 0 10th Dec 2004 07:39 AM
Minimized Parent Form when its child form is minimized =?Utf-8?B?VGFp?= Microsoft Dot NET 1 5th Jul 2004 07:16 AM
Dotnet scheduler like the Windows "Schedued Tasks" scheduler? Codemonkey Microsoft Dot NET 11 10th Dec 2003 11:11 AM
Minimized docs don't remain minimized when opening new doc =?Utf-8?B?V2F5bmU=?= Microsoft Word Document Management 0 6th Dec 2003 01:21 AM
New window links open a minimized window; minimized window is bar at top lr sachs Windows XP Internet Explorer 1 17th Sep 2003 01:58 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:06 AM.