Solved

Scheduling a bat file to run with task scheduler not working

Posted on 2014-10-07
10
49 Views
Last Modified: 2015-06-27
I created a bat file that calls up a VB script that checks whether a a specific server service is up or not. The script also sends an email to us on whether it's up or not.

This is in my bat file = CSCRIPT monitor.vbs LOCALHOST "server service"

The bat and VB script runs fine. No errors and i get the emails generated. However I can't seem to get the bat file to work with task scheduler at all.

No emails are being generated. It should even when the service is running. I thought maybe it was my bat file causing problems.  I removed the bat file and just tried to use task scheduler to open a notepad. I hit run in task scheduler and the 'history' shows that it did but I did not see notepad open up at all.

I don't care about note pad not working but i do need my bat file to run. what am I missing?
0
Comment
Question by:iamuser
  • 3
  • 2
  • 2
  • +2
10 Comments
 
LVL 4

Expert Comment

by:AnthonyHamon
ID: 40366650
Try using the full path to the monitor.vbs script.

Regarding your test with Notepad, by default a scheduler job runs under the LOCALSYSTEM account, so it is normal that you do not see the Notepad window.
0
 
LVL 9

Expert Comment

by:bas2754
ID: 40366652
A few things:

1.  Are you set to run it with highest privileges in the the task scheduler options?
2. What user are you running it as?
3.  Is it set to run in Interactive Mode?

These are a few initial things to check.
0
 

Author Comment

by:iamuser
ID: 40366668
I will try the full path

1. highest privilege box checked
2. domain admin
3. run whether user is logged on or not
0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
LVL 9

Expert Comment

by:bas2754
ID: 40366676
Then as the other author posted, I would try the full path AND specify the startup folder as well.
0
 
LVL 14

Expert Comment

by:ThomasMcA2
ID: 40366768
For debugging purposes, change your script to generate a log file. Then you can check the log file to monitor the status of the job. I leave this kind of logging in several of my scripts so I can easily review what my script did days after the fact. For example,

Echo %date% %time% About to do XYZ step >> C:\Logs\job1.log

Open in new window

0
 

Author Comment

by:iamuser
ID: 40367013
so you added the log line to the end of your script. And you script still ran or did you just have the script log to a file ?
0
 
LVL 14

Expert Comment

by:ThomasMcA2
ID: 40367056
Put those echo commands anywhere in your script where you want to check something. For example, put it at the very beginning to confirm that the script starts, and/or put it before Step 4 to confirm that the script gets to that point in your script. Sometimes I even put an echo command as the very last line of my script so that I know that it "ended normally." During development, I may add/remove several echo commands just to confirm that it runs.
0
 

Accepted Solution

by:
iamuser earned 0 total points
ID: 40413636
I resolved it. it was something off in the VBscript, thanks all
0
 
LVL 34

Expert Comment

by:Seth Simmons
ID: 40854425
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Utilizing an array to gracefully append to a list of EmailAddresses
New Windows 7 Installations take days for Windows-Updates to show up and install. This can easily be fixed. I have finally decided to write an article because this seems to get asked several times a day lately. This Article and the Links apply to…
This tutorial will walk an individual through the steps necessary to install and configure the Windows Server Backup Utility. Directly connect an external storage device such as a USB drive, or CD\DVD burner: If the device is a USB drive, ensure i…
This tutorial will walk an individual through the process of installing the necessary services and then configuring a Windows Server 2012 system as an iSCSI target. To install the necessary roles, go to Server Manager, and select Add Roles and Featu…

825 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question