Jump to content

Welcome to MSFN Forum
Register now to gain access to all of our features. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, post status updates, manage your profile and so much more. This message will be removed once you have signed in.
Login to Account Create an Account



Photo

Task Schedule problem


  • Please log in to reply
5 replies to this topic

#1
zeezam

zeezam

    Member

  • Member
  • PipPip
  • 146 posts
  • Joined 28-March 08
I have created a script that copy and move a file with wget. I saved the script in .cmd.

If I manually run the script it works.
I have created a task in windows 2008 that will run the job every week.
The job seems to run in the job history but it doesn't do it's job.

Any ideas?

How to track down this?


How to remove advertisement from MSFN

#2
Tripredacus

Tripredacus

    K-Mart-ian Legend

  • Super Moderator
  • 9,923 posts
  • Joined 28-April 06
  • OS:Server 2012
  • Country: Country Flag

Donator

You should add some error handling/logging into your script, such as creating a token somewhere (easiest copying a text file) or even writing to the Application Event Log. Basically, if a .cmd fails, you won't see it as a fail in the job history, because a .cmd will always just do a successful exit under most circumstances, since cmd doesn't really pay attention to what you are having it do. If the programs themselves are failing, they would be the one to generate the error, not cmd, which is why it doesn't "fail" in the log.
MSFN RULES | GimageX HTA for PE 3-5 | lol probloms
msfn2_zpsc37c7153.jpg

#3
zeezam

zeezam

    Member

  • Member
  • PipPip
  • 146 posts
  • Joined 28-March 08

You should add some error handling/logging into your script, such as creating a token somewhere (easiest copying a text file) or even writing to the Application Event Log. Basically, if a .cmd fails, you won't see it as a fail in the job history, because a .cmd will always just do a successful exit under most circumstances, since cmd doesn't really pay attention to what you are having it do. If the programs themselves are failing, they would be the one to generate the error, not cmd, which is why it doesn't "fail" in the log.


Ok.

This must have something to do with how windows 2008 start the script or something, because if I run it manually it works.
The same script did work on a windows 2003 as a schedule task.

#4
Tripredacus

Tripredacus

    K-Mart-ian Legend

  • Super Moderator
  • 9,923 posts
  • Joined 28-April 06
  • OS:Server 2012
  • Country: Country Flag

Donator

Its more likely to do with permissions. When you run it "manually" you run it under your user account. When it is run by Task Scheduler, it is run under an OS account. Try changing the account that is used to run the task.
MSFN RULES | GimageX HTA for PE 3-5 | lol probloms
msfn2_zpsc37c7153.jpg

#5
allen2

allen2

    Not really Newbie

  • Member
  • PipPipPipPipPipPipPip
  • 1,814 posts
  • Joined 13-January 06
Or check if the box "run with highest privilege" is checked.

#6
zeezam

zeezam

    Member

  • Member
  • PipPip
  • 146 posts
  • Joined 28-March 08

Or check if the box "run with highest privilege" is checked.


It did the trick! :)




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users