Solved

Scheduled Task won't launch .bat or .vbs

Posted on 2011-03-08
16
4,610 Views
Last Modified: 2012-05-11
I can't get GPO-based Scheduled Task to launch .bat or .vbs on Windows7 client machine.

We have Sever2008 domain controllers - I'm using typical GPO settings (Computer -> Preferences -> Control Panel -> Scheduled Tasks) to set a task to run under "System" authority.  I've tried making it launch .bat and .vbs files, and it won't do either.  These are very basic (helloworld.bat and msgbox.vbs - have been scripting for years).  

After reboot, I go into "Scheduled Tasks" on the client and I see the task.  It kicks off at the appropriate time, and it shows "The task is currently running (0x41301)" - however, it never actually launches the batch file or the script (I've tried a variety of versions - either trying to run a .bat or a .vbs (vbs running under wscript.exe).  I never get the response I expect to see (a popup box showing "Hello World") to indicate that the script/batch file is actually running.

Thanks...DavidS
0
Comment
Question by:DWStovall
  • 5
  • 3
  • 3
  • +1
16 Comments
 
LVL 27

Expert Comment

by:Steve
ID: 35071922
So the scheduled task is applied to the PC, it just doesnt work. is that correct?
What location have you specified for the batch file? is it on a server share on on the PCs?
0
 

Author Comment

by:DWStovall
ID: 35072156
Created a GPO which includes settings (path in previous mesage) to create a Scheduled Task to run under System authority.  RSOP shows that the policy applied, the Task Scheduler Library on the client machine shows the task.  The task is set to run a "hello.bat" from the C:\ root.  The hello.bat is on the client's C:\ root.  The hello.bat runs perfectly (very simple HelloWorld popup) when I launch it manually on the client machine either by double-clicking it in a standard window or launching it as a command line from a prompt - the batch file runs just fine.  The scheduled task (created by the GPO) launches at the prescribed time, the "Status" shows that it is "Running", the history (in the Task Scheduler shows all the expected steps (Task Registered, Task Triggered, Task Started, Action Started, etc), but it never actually runs the script.  I've checked and double checked all the security settings for the batch file, and everything should work.  It's as if there is a Security Policy setting to not launch .bat or .vbs from a Scheduled Tasks.  I've been working on this for days.  My next step is to repair/rebuild the client.
0
 
LVL 47

Accepted Solution

by:
Donald Stewart earned 500 total points
ID: 35072953
This is because the task is running under the context of "System" and not of the user that's logged in

read here

http://technet.microsoft.com/en-us/library/cc722152.aspx
0
Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

 
LVL 27

Expert Comment

by:Steve
ID: 35100011
ah, yes. you've set it to run as system. this will not interact with the desktop, although I think there may be a setting you can change that will enable desktop interaction.
0
 

Author Comment

by:DWStovall
ID: 35360059
I disagree...it wasn't a solution.  I had already tried the solution by dstewartjr.  
0
 
LVL 47

Expert Comment

by:Donald Stewart
ID: 35360077
Having a hard time believing that
0
 

Author Comment

by:DWStovall
ID: 35360090
I believe this is a result of improper group policy settings.  We've since abandoned the approach.  I am not opposed to awarding the points as suggested, but the solution was not a solution and should not be designated as one - it would be misleading.

I apologize for not responding to the posts.  I will try to be more responsive in the future.

Thank you...
0
 
LVL 47

Expert Comment

by:Donald Stewart
ID: 35360124
Sorry, but I disagree

"Created a GPO which includes settings (path in previous mesage) to create a Scheduled Task to run under System authority. "


A scheduled task that runs under the "System" context will *Not* be visible to the logged on user. Nothing to do with Group Policy.

My answer was posted on prior experience with this issue.

In fact the only way I've found to get a task to run interactively as another user is to use "AT"

http://support.microsoft.com/kb/313565

0
 
LVL 69

Expert Comment

by:Qlemo
ID: 35361261
The first link provided does not tell us anything about the issue at hand - it is a description of general task properties, and some account restrictions, but nothing regarding interaction with the desktop.

The AT link does not work on Vista and later anymore as described. AT always runs with SYSTEM account, and ignores the "/interactive" switch (SYSTEM cannot interact with the user desktop, as correctly stated).

However, if you start tools like msg.exe for sending popups, that works in all variations, even when called from a batch file.

The only way to get an interactive cmd prompt is by having the job run under the current login credentials, and with the setting "Run only when user is logged on".
0
 
LVL 27

Expert Comment

by:Steve
ID: 35366333
There are several reasons we could suggest as the cause:

Improper GPO settings
Issues with WIN7 and interactive 'System' processes
Batchfile errors

Without establishing which, I think it's probably best to delete the question and drop it.
It sucks to participate without getting points for your work but we cannot profess to have provided the solution as the asker dropped the issue without success.
0
 

Author Comment

by:DWStovall
ID: 35379551
I recommend closing the ticket and starting over.  I will do more research to better determine the condition under which the task was not working.  I will then be able to better document the case and resubmit.  

I apologize for the submitting the question and creating such a mess.

DavidS
0
 

Author Closing Comment

by:DWStovall
ID: 35393935
It wasn't a complete solution - only pointed in the general direction.
0

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

When you try to share a printer , you may receive one of the following error messages. Error message when you use the Add Printer Wizard to share a printer: Windows could not share your printer. Operation could not be completed (Error 0x000006…
This article explains how to install and use the NTBackup utility that comes with Windows Server.
This Micro Tutorial will teach you the basics of configuring your computer to improve its speed. It will also teach you how to disable programs that are running in the background simultaneously. This will be demonstrated using Windows 7 operating…
This Micro Tutorial will give you basic overview of the control panel section on Windows 7. It will depth in Network and Internet, Hardware and Sound, etc. This will be demonstrated using Windows 7 operating system.

828 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