Author Topic: Windows "script" not running via Task Scheduler  (Read 1611 times)

mtnbkr

  • friend
  • Senior Member
  • ***
  • Posts: 15,388
Windows "script" not running via Task Scheduler
« 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

GigaBuist

  • friends
  • Senior Member
  • ***
  • Posts: 4,345
    • http://www.justinbuist.org/blog/
Re: Windows "script" not running via Task Scheduler
« Reply #1 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?

AZRedhawk44

  • friends
  • Senior Member
  • ***
  • Posts: 13,977
Re: Windows "script" not running via Task Scheduler
« Reply #2 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.
"But whether the Constitution really be one thing, or another, this much is certain - that it has either authorized such a government as we have had, or has been powerless to prevent it. In either case, it is unfit to exist."
--Lysander Spooner

I reject your authoritah!

Ben

  • Administrator
  • Senior Member
  • *****
  • Posts: 46,135
  • I'm an Extremist!
Re: Windows "script" not running via Task Scheduler
« Reply #3 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.
"I'm a foolish old man that has been drawn into a wild goose chase by a harpy in trousers and a nincompoop."

mtnbkr

  • friend
  • Senior Member
  • ***
  • Posts: 15,388
Re: Windows "script" not running via Task Scheduler
« Reply #4 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

roo_ster

  • Kakistocracy--It's What's For Dinner.
  • friend
  • Senior Member
  • ***
  • Posts: 21,225
  • Hoist the black flag, and begin slitting throats
Re: Windows "script" not running via Task Scheduler
« Reply #5 on: July 13, 2010, 10:26:21 PM »
Lord, do I hate me some Windows Task Bedeviler.
Regards,

roo_ster

“Fallacies do not cease to be fallacies because they become fashions.”
----G.K. Chesterton

mtnbkr

  • friend
  • Senior Member
  • ***
  • Posts: 15,388
Re: Windows "script" not running via Task Scheduler
« Reply #6 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

GigaBuist

  • friends
  • Senior Member
  • ***
  • Posts: 4,345
    • http://www.justinbuist.org/blog/
Re: Windows "script" not running via Task Scheduler
« Reply #7 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?

mtnbkr

  • friend
  • Senior Member
  • ***
  • Posts: 15,388
Re: Windows "script" not running via Task Scheduler
« Reply #8 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

Ben

  • Administrator
  • Senior Member
  • *****
  • Posts: 46,135
  • I'm an Extremist!
Re: Windows "script" not running via Task Scheduler
« Reply #9 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

 
"I'm a foolish old man that has been drawn into a wild goose chase by a harpy in trousers and a nincompoop."

AZRedhawk44

  • friends
  • Senior Member
  • ***
  • Posts: 13,977
Re: Windows "script" not running via Task Scheduler
« Reply #10 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.
"But whether the Constitution really be one thing, or another, this much is certain - that it has either authorized such a government as we have had, or has been powerless to prevent it. In either case, it is unfit to exist."
--Lysander Spooner

I reject your authoritah!

Ben

  • Administrator
  • Senior Member
  • *****
  • Posts: 46,135
  • I'm an Extremist!
Re: Windows "script" not running via Task Scheduler
« Reply #11 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.
"I'm a foolish old man that has been drawn into a wild goose chase by a harpy in trousers and a nincompoop."