none
Bat file run from Windows 7 Task Scheduler - runs from command line, access denied from scheduled task

    Question

  • I am porting scheduled tasks (which have worked for quite some time) from a Windows XP machine to a new Windows 7 machine.  The user account on both machines is an administrator, and has read-write access to a mapped drive on a network share.  The batch files run successfully from the command line on the new machine.  On the new machine the task is scheduled to run with highest privileges. When it completes the message is that it completed successfully, but files that should be copied to the network share are not there:

    Task Scheduler successfully completed task "\mmis_daily_834" , instance "{80671614-819b-4311-9fc9-5deb1ee496d8}" , action "C:\Windows\SYSTEM32\cmd.exe" with return code 0.

    Monday, November 05, 2012 7:16 PM

Answers

  • When you run the task from command line, it is run as currently logged on user.

    When it is run from scheduled tasks it is run as the computer. It is OK as long as source and destination data is on the same computer. However, if the destination is remote computer, the remote computer will ask for authentication. So, if you ran from command line and if you authenticated before, it will be OK.

    Anyway, to cut the long story, configure your task to authenticate (specify user name and password). Again, this works better if both source and destination computers are members of domain. If  they are members of workgroup, it may get tricky.

    Tuesday, November 06, 2012 7:19 PM

All replies

  • Sorry, can't tell without seeing the batch file.
    Monday, November 05, 2012 9:00 PM
  • When you run the task from command line, it is run as currently logged on user.

    When it is run from scheduled tasks it is run as the computer. It is OK as long as source and destination data is on the same computer. However, if the destination is remote computer, the remote computer will ask for authentication. So, if you ran from command line and if you authenticated before, it will be OK.

    Anyway, to cut the long story, configure your task to authenticate (specify user name and password). Again, this works better if both source and destination computers are members of domain. If  they are members of workgroup, it may get tricky.

    Tuesday, November 06, 2012 7:19 PM
  • When you run the task from command line, it is run as currently logged on user.

    When it is run from scheduled tasks it is run as the computer.

    May be, may be not. This depends entirely on how the OP configured the task. Note also that there is no "computer" account to run tasks. You're probably thinking of the "System" account.
    Tuesday, November 06, 2012 7:36 PM