Scheduled Task Isn't Running Part of Bat script

oakridgeschools used Ask the Experts™
I have some weird things going on with this. If I run this script by double clicking on it (or using a command prompt), it runs fine. If I run this with a scheduled task, all that seems to run is the first line. Does anybody have any ideas why it isn't running the VB? This script works perfectly otherwise.

We're working with Windows XP.
shutdown -s -t 300
@echo off
echo Set objshell = CreateObject("") > %temp%\abort.vbs
echo strAnswer = MsgBox("Abort shutdown?",vbYesNo+vbSystemModal) >> %temp%\abort.vbs
echo If strAnswer = 6 Then >> %temp%\abort.vbs
echo objshell.Run("shutdown -a") >> %temp%\abort.vbs
echo End if >> %temp%\abort.vbs


Open in new window

Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

A scheduled task will run as the account it runs at so most likely you won't see the messagebox, is ther a cscript.exe still running by any chance?



Sorry... I'm not well versed in VB. I just put that script together with the help of some others here on EE. How can I check on the cscript, and is there any way to display that message to any user that is on the computer vs just the one the task is running as?
Look in process list (control alt delete) and you will no doubt see a process cscrip waiting which you'll have to end task.  I don't have the syntax of schtasks command here to check at the moment and just on way out so maybe someone else can dive in.  You can do this with the AT command to make the task interact with the user with a command along hte lines of:

at \\computername hh:mm /interactive "command"
Introduction to R

R is considered the predominant language for data scientist and statisticians. Learn how to use R for your own data science projects.

Tech Lead (Windows), Endpoint Device Management Services
Hi oakridgeschools,

What account are you running it as within the scheduled task?

If you are running it as SYSTEM then you will not see the message box generated by this line in the VBScript:

strAnswer = MsgBox("Abort shutdown?",vbYesNo+vbSystemModal)

This is because programs run by SYSTEM from the task scheduler are non-interactive, i.e. no interaction with the logged on session.  So what happens is the message box sits there where you cannot get to it, and the system shutdown counts down and completes.  In actual fact the script is almost certainly working perfectly but invisibly.

What you can do is instead of calling your batch file directly from the scheduled task, have it call PSExec instead ( and use the batch file as an argument to PSExec.

Hope this helps,


Hey guys. Sorry for the delay on response. Summer has hit, and with it, summer projects. Daz, I took a look at your link, and your logic makes sense. We're going to give this a shot.
Guy Hengel [angelIII / a3]Billing Engineer
Most Valuable Expert 2014
Top Expert 2009

This question has been classified as abandoned and is being closed as part of the Cleanup Program. See my comment at the end of the question for more details.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial