Kitz ADSL Broadband Information
adsl spacer  
Support this site
Home Broadband ISPs Tech Routers Wiki Forum
 
     
   Compare ISP   Rate your ISP
   Glossary   Glossary
 
Please login or register.

Login with username, password and session length
Advanced search  

News:

Author Topic: Windows Scheduler - Running Batch files silently  (Read 14785 times)

Bald_Eagle1

  • Helpful
  • Kitizen
  • *
  • Posts: 2721
Windows Scheduler - Running Batch files silently
« on: November 20, 2011, 12:23:38 AM »

Hi All,

Do any of you know how to run a batch file silently via Windows Scheduler.

I currently have a batch file running every 2 minutes & would like to run it every minute (or even more frequently if possible).

The problem is that it pops up a CMD window for a second or two each time it runs.
Once every 2 minutes is just about tolerable, but every minute would be a real P.I.T.A.

This is very annoying when working at the PC & I would like it to run minimised, or completely hidden.

Do any of you know of a way to do this?

Batch files cannot be set to run minimised, but a shortcut to one can (normally).
This trick doesn't seem to work when using Scheduler though, unless I am just missing an obvious setting somewhere.

I would like to enable this feature for XP, Vista, & Windows 7 machines.

Paul.
Logged

tuftedduck

  • Senior Kitizen
  • ******
  • Posts: 29658
  • Router Luvvin Duck
Logged

Bald_Eagle1

  • Helpful
  • Kitizen
  • *
  • Posts: 2721
Re: Windows Scheduler - Running Batch files silently
« Reply #2 on: November 20, 2011, 10:43:53 PM »

Does Section 6 here help you ?

http://serverfault.com/questions/9038/run-a-bat-file-in-a-scheduled-task-without-a-window

Hi tuftedduck,

I think I have tried every combination of the various suggestions in that link.
With some, the batch file (and/or its shortcut) didn't run at all & with the others it ran, but still popped up the annoying CMD window.

I have only got this to work via various BAT to EXE converters, using very simple batch files.

However, as I want to pass the batch file around, with the ability to edit it as necessary, this doesn't seem a good option.
Also, all the "free" BAT to EXE converters I have tried do not allow the resulting EXE to run on anyone else's PC.

I also believe the BAT to EXE converters struggle with environment variable that are set in a batch file & are often classed as a virus by many/most AV programs.

I'll keep looking for a method to resolve this, but any other suggestions would be most welcome.


Paul.
Logged

Bald_Eagle1

  • Helpful
  • Kitizen
  • *
  • Posts: 2721
Re: Windows Scheduler - Running Batch files silently
« Reply #3 on: November 21, 2011, 10:10:26 AM »

Hi,

I have found a scheduler for Windows that works perfectly sliently (z-cron), apart from the maximum frequency for tasks being 5 minutes rather than the 1 minute I require.

I have emailed their support team to see if this frequency can be adjusted at all, but it might be back to the drawing board  :(


Paul.
Logged

Bald_Eagle1

  • Helpful
  • Kitizen
  • *
  • Posts: 2721
Re: Windows Scheduler - Running Batch files silently
« Reply #4 on: November 27, 2011, 05:12:36 PM »


I have found a scheduler for Windows that works perfectly sliently (z-cron), apart from the maximum frequency for tasks being 5 minutes rather than the 1 minute I require.



Quick update - success.


I have finally resolved this via Windows Scheduler itself.

The steps necessary are:-

1) Create the "real" batch file e.g. DOSOMETHING.BAT

2) Create another batch file that contains the single line "DOSOMETHING.BAT>nul" (no spaces) & name it something like "Run_DOSOMETHING.BAT". The >nul part forces it to not display any output, but it still pops up a black CMD window.

3) Create a shortcut to "RunDOSOMETING.BAT" that will be automatically named "Run_DOSOMETHING.BAT - Shortcut" & instruct it to run Minimized in its "Properties" tab.
That hides the pop up CMD window, but the task bar icons can still be seen expanding & contracting as the batch file(s) run.

4) Create a scheduled task to actually run the shortcut at whatever intervals are required, but in the "Action" section enter the program as "Run_DOSOMETHING.BAT - Shortcut.lnk"
The addition of ".lnk" is necessary, otherwise the normal .BAT file will run.
If asked if you want to run the task with arguments, choose NO.

5) Choose to run the task "whether user is logged on or not", also entering your usual Windows logon password (if requested).

Job done.

The above certainly works for Windows 7, & I imagine a similar procedure will work for previous Windows versions too.

Absolutely no sign of the batch file(s) running can be seen, apart from the dates/times of the files being created/updated as output from the batch file(s) auto-updating. Even this is only visible if actually viewing the relevant folder at the time.

The scheduled task now runs as a Windows "Service" thus there is no danger of accidentally stopping it.


Paul.
Logged

burakkucat

  • Global Moderator
  • Senior Kitizen
  • *
  • Posts: 31086
  • Over the Rainbow Bridge
    • The ELRepo Project
Re: Windows Scheduler - Running Batch files silently
« Reply #5 on: November 27, 2011, 07:27:57 PM »

Congratulations for your success.  :clap:  :dance:

I must say it is a very convoluted rigmarole  . . .  :-X
A simpler solution would be to throw out that computer infested with the Redmond Company's Virus (a.k.a. Windoze:comp:  and use one which has a proper operating system installed!  :thumbs:
Logged
:cat:  100% Linux and, previously, Unix. Co-founder of the ELRepo Project.

Please consider making a donation to support the running of this site.

Bald_Eagle1

  • Helpful
  • Kitizen
  • *
  • Posts: 2721
Re: Windows Scheduler - Running Batch files silently
« Reply #6 on: November 27, 2011, 11:50:10 PM »

A simpler solution would be to throw out that computer infested with the Redmond Company's Virus (a.k.a. Windoze:comp:  and use one which has a proper operating system installed!  :thumbs:



Ah, but wouldn't life be so boring without all these little interesting things sent to try us?  ;)

Logged

geep

  • Reg Member
  • ***
  • Posts: 452
    • My ST546 Statistics
Re: Windows Scheduler - Running Batch files silently
« Reply #7 on: November 29, 2011, 09:22:02 PM »

What you need,perhaps, is pycron - http://www.kalab.com/freeware/pycron/pycron.htm
It brings the Linux/Unix cron facilities to Windows. Seems it can run every minute, just like the "real" cron.

Cheers,
Peter
Logged

Bald_Eagle1

  • Helpful
  • Kitizen
  • *
  • Posts: 2721
Re: Windows Scheduler - Running Batch files silently
« Reply #8 on: November 29, 2011, 09:38:38 PM »

Cheers geep,

I might give that a go at some time, but I'm reasonably happy now that I have got Windows Task Scheduler to do just what I needed for the specific purpose of harvesting my FTTC modem's stats 24/7.


Paul.
Logged

burakkucat

  • Global Moderator
  • Senior Kitizen
  • *
  • Posts: 31086
  • Over the Rainbow Bridge
    • The ELRepo Project
Re: Windows Scheduler - Running Batch files silently
« Reply #9 on: November 29, 2011, 09:44:22 PM »

Anyone seen Mary recently?

Perhaps she would like to post to this thread?

Having made that observation, b*cat now goes to hide . . .  :)
Logged
:cat:  100% Linux and, previously, Unix. Co-founder of the ELRepo Project.

Please consider making a donation to support the running of this site.

Bald_Eagle1

  • Helpful
  • Kitizen
  • *
  • Posts: 2721
Re: Windows Scheduler - Running Batch files silently
« Reply #10 on: November 30, 2011, 10:58:41 AM »

Anyone seen Mary recently?

Perhaps she would like to post to this thread?

Having made that observation, b*cat now goes to hide . . .  :)


Last time I saw her, she was leaving on a jet plane.

I'll get my coat now then.
Logged

burakkucat

  • Global Moderator
  • Senior Kitizen
  • *
  • Posts: 31086
  • Over the Rainbow Bridge
    • The ELRepo Project
Re: Windows Scheduler - Running Batch files silently
« Reply #11 on: November 30, 2011, 04:58:31 PM »

For those who do not understand this cat - eagle interaction, look at the very last word in Messrs Geep & Eagle individual posts and then look at this Wikipedia link:P
Logged
:cat:  100% Linux and, previously, Unix. Co-founder of the ELRepo Project.

Please consider making a donation to support the running of this site.

roseway

  • Administrator
  • Senior Kitizen
  • *
  • Posts: 39682
  • Penguins CAN fly
    • DSLstats
Re: Windows Scheduler - Running Batch files silently
« Reply #12 on: November 30, 2011, 06:35:28 PM »

I was wondering what it was about :-[
Logged
  Eric
 

anything