0

My goal is to have a batch script that checks windows services to see if they're running and output a .csv report. I also want this batch script to run hourly via Windows Task Scheduler.

Here is a script I was given to and am using for the example:

type null > servicecheckupreport.csv 
sc query "AdobeARMservice" >> servicecheckupreport.csv 
sc query "aspnet_state" >> servicecheckupreport.csv 
sc query "AdobeFlashPlayerUpdateSvc" >> servicecheckupreport.csv 

I am checking three (example) services, AdobeARMservice, aspnet_state and AdobeFlashPlayerUpdateSvc.

The batch works fine when you manually execute it, however when I successfully connect it to Windows Task Scheduler using the "Create Basic Task" feature, the batch script runs, but doesn't generate the .csv report. I can see the command prompt come up for a little bit, goes away and then that's it.

Lasagna Cat
  • 297
  • 3
  • 24
  • 2
    a schedule task will start in another initial folder. Spend it a `cd "%~dp0" to change it to the same folder, where your script resides. – Stephan Mar 21 '17 at 17:11
  • 1
    ...add `/D` to the `cd` command to also change the drive, if necessary... – aschipfl Mar 21 '17 at 17:15
  • You are correct, thanks. I would like to send the .csv to my Y drive. Can I do `sc query "AdobeARMservice" >> Y:\servicecheckupreport.csv` and would it be accepted in Windows Task Scheduler? – Lasagna Cat Mar 21 '17 at 17:27

0 Answers0