windowsbatch-filescheduled-tasksdrive-mapping

Batch file called by scheduled task throws error when scheduled, runs fine when double clicked


I have a batch file that maps a networked drive. About a week or so ago the password expired, so the program calling the batch file started throwing errors.

I've updated the password in the batch file, and when I double click on the batch file, the drive maps fine. However, when the scheduled task kicks off, I get the following error:

Logon failure: unknown user name or bad password.

Anyone seen this before? I've tried recreating the scheduled task, but it doesn't seem to make any difference.

EDIT

I've updated the properties of the scheduled task, which isn't the problem. The problem seems to be the username and password in the batch file. The strange thing is if I log on interactively and double click the executable, everything works perfectly.

The last time the job ran it threw a "semaphore timeout period has expired" error. I've never seen this particular error before, but it seems like it was actually logged on and trying to copy files when this happened.

EDIT

I've revised my code to make it as simple as possible. I'm using a batch file to map the drive, then using code to transfer the files. I still run into the same issue - it works fine when I double click the batch file, but once I throw Scheduler into the picture, it throws a "Bad username or invalid password" error.

Occasionally when I'm trying to run the file by double clicking on it, I get a "Could not find part of the path" error. This says to me the drive mapping actually worked but something failed when it was trying to copy. (Most of the time, testing by double clicking works fine)


Solution

  • The username and password associated with the task when you created it is no longer valid or has changed. This occurs generally when creating the task and forgetting to select the option not to store the password. When your password is set to expire, then you will meet this problem everytime you will have to reset your password. Make sure to do as on the image : enter image description here