Armed Polite Society

Main Forums => The Roundtable => Topic started by: mtnbkr on July 13, 2010, 03:45:35 PM

Title: Windows "script" not running via Task Scheduler
Post by: mtnbkr on July 13, 2010, 03:45:35 PM
On my desktop at home, I have the normal file storage locations (My Docs, etc).  I back those up to a second internal drive with an Xcopy command in a batch file.  It runs daily via the Task Scheduler.  I have another script, very similar, but more detailed, that copies that data from the 2nd drive to my server on the LAN.  That is the script that fails.  If I run it manually, it runs without fault.  If I rely on Task Scheduler, it never runs even though the log says it does (no files copied and the total run duration is 0 seconds).

Everything is configured exactly like the first task.  If I run it manually, everything is ok. 

Any ideas?

Chris
Title: Re: Windows "script" not running via Task Scheduler
Post by: GigaBuist on July 13, 2010, 03:49:43 PM
Mind posting the script?  Any error messages show up when you run it manually?  Anything in Event Viewer?
Title: Re: Windows "script" not running via Task Scheduler
Post by: AZRedhawk44 on July 13, 2010, 03:55:40 PM
authentication, is my guess.

Your script to the remote server is not authenticating, or is assuming a mapped drive exists that you may see while you're logged in, but not necessarily when the script is logged in (the script may not operate under your user permissions).

Run a deliberate NET USE command, including authentication credentials, prior to the XCOPY command.
Title: Re: Windows "script" not running via Task Scheduler
Post by: Ben on July 13, 2010, 04:05:54 PM
authentication, is my guess.

I'd guess this too. I run into this problem auto-backing up files to my fileserver at work using the win backup function. I have to change my OU admin password every 45 days and everytime I do the backup fails to authenticate until I reset the backup. If I tell it to "run now" it runs just fine.
Title: Re: Windows "script" not running via Task Scheduler
Post by: mtnbkr on July 13, 2010, 05:11:58 PM
No error messages.
The script ran fine from task scheduler when it was used on a Windows XP system prior to the Win7 system being built.
I think I set the script to run from my user account rather than the system account.  I'll confirm tonight.

Chris
Title: Re: Windows "script" not running via Task Scheduler
Post by: roo_ster on July 13, 2010, 10:26:21 PM
Lord, do I hate me some Windows Task Bedeviler.
Title: Re: Windows "script" not running via Task Scheduler
Post by: mtnbkr on July 14, 2010, 06:24:12 AM
Confirmed, it runs as "me", which means it has the appropriate rights to access the remote drive.

This worked fine under XP.  I had it running on two different machines back then.

Chris
Title: Re: Windows "script" not running via Task Scheduler
Post by: GigaBuist on July 14, 2010, 09:25:42 AM
This worked fine under XP.  I had it running on two different machines back then.

Perhaps UAC is getting in the way then?
Title: Re: Windows "script" not running via Task Scheduler
Post by: mtnbkr on July 14, 2010, 09:39:26 AM
If so, it isn't giving any warnings.  It's pretty simple.  It uses xcopy to copy changed files from the local drive to a network drive.  The user accounts are synced and the script runs flawlessly when manually initiated.  A similar script works fine when copying from the C: drive to another internal drive.  The same data is being moved each time (from C: to E: to Z: (network).

I had an "If Exists Z:" statement in the beginning so it wouldn't churn if the share wasn't available.  I thought maybe that was causing timing issues, so I removed it.  No change.

Chris
Title: Re: Windows "script" not running via Task Scheduler
Post by: Ben on July 14, 2010, 10:07:24 AM
I don't know much about Xcopy, but did a quick Google because I wanted to see what all it can do, so stupid amateur question, but I saw the below example script for network backup where they mention adding switches to ignore errors in network restartable (I actually don't know what that is) mode. Don't know if this would override a stop error or not?

---------------------------
Copy entire drive in to a mapped network drive while ignoring any errors in network restartable mode.

xcopy *.* z:\Netmirror /E /V /C /F /H /Y /Z  1>out.txt 2>err.txt

 
Title: Re: Windows "script" not running via Task Scheduler
Post by: AZRedhawk44 on July 14, 2010, 10:48:15 AM
I don't think it's going to be anything in the XCOPY command, or else it would have been present prior to the change from XP to Win7.
Title: Re: Windows "script" not running via Task Scheduler
Post by: Ben on July 14, 2010, 10:57:24 AM
I wonder if the same error would pop up using robocopy instead of xcopy? I don't know much about robocopy either, just throwing it out there.