Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Scheduled task not working 1

Status
Not open for further replies.

jasonp45

Programmer
Aug 23, 2001
212
US
I have several VBScripts I run via Scheduled Tasks; they work fine.

However I just created a new one and it won't work.

If I click the VBS file to activate the script it executes perfectly (uses Robocopy to synchronize two folders).

When the Scheduled Task runs, the task shows as having run with no errors, yet absolutely nothing happens - no files are copied, no DOS window appears on the task bar, etc.

Has anyone encountered this?

I am on XP64, but this hasn't affected any of my other scheduled tasks or VBScripts.
 
Is there anything odd or unusual about the length of time that the task was running according to the log. Did it only run for a couple of seconds etc. but when running manually did it take much longer to complete?


What is recorded in the SchedLgU.log in the Windows folder?
Ideally you should see something like this for each scheduled task.


"temp.job" (temp.bat)
Started 4/12/2004 7:43:40 PM
"temp.job" (temp.bat)
Finished 4/12/2004 7:43:41 PM
Result: The task completed with an exit code of (0).


What exit code are you seeing?







How to troubleshoot scheduled tasks in Windows XP and in Windows Server 2003

How to modify scheduled tasks in Windows XP

How to use Schtasks.exe to Schedule Tasks in Windows Server 2003
 
Yep, that's pretty much what I'm seeing:
Code:
"Clone_MyFolder.job" (Clone_MyFolder.vbs)
	Started 3/24/2008 1:23:00 PM

"Clone_MyFolder.job" (Clone_MyFolder.vbs)
	Finished 3/24/2008 1:23:00 PM
	Result: The task completed with an exit code of (0).

When I run the VBS manually it takes about 5 seconds to run - long enough to see the Command task appear in my task bar and click on it.
 
If you are running manually first to test your coding, followed by a scheduled task soon after, perhaps there is nothing for the scheduled task to do?
 
Thanks, but I thought of that.

The way I'm testing is I put a couple of test files in the directory I'm cloning, then I run the script and see if they show up in the target folder; they do.

Then I delete them from the target folder, schedule the task for 2 minutes in the future, and wait for it to run. It runs, exits with 0...but doesn't copy the test files.
 
What happens if you change the names of the test files in the source folder, does it then run successfully?
 
I figured it out...essentially it was due to the oddities surrounding 64-bit/32-bit incompatibilities on XP64.

My script was running RoboCopy.exe, which is in my SysWOW64 folder. When I click the script, it runs fine.

Yet when the script is called by a Scheduled Task (which is presumably a 64-bit service), it somehow spawns the script in a 64-bit mode (probably the cmd.exe is 64-bit rather than 32-bit), which must exclusively look for RoboCopy in the System32 folder (which, very unintuitively, contains the 64-bit system files under XP64; 32-bit files are in the SysWOW64 folder!).

So running "Cmd.exe /C RoboCopy [SourceFolder] [TargetFolder]" did nothing - no errors were produced by the task, yet nothing happened. It's possibly the script was generating an error but I wasn't getting a message box.

The fix was simple: fully qualify the path to Robocopy:
"Cmd.exe /C C:\Windows\SysWOW64\RoboCopy.exe [SourceFolder] [TargetFolder]"

Now the task works fine.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top