Batch file that is called on scheduled task throws an error when scheduling, works fine on double click

I have a batch file that maps a network drive. After about a week, the password expired, so the program calling the batch file started throwing errors.

I have updated the password in the batch file and when I double click on the batch file the disk looks fine. However, when the scheduled job starts, I get the following error:

Logon failure: unknown user name or bad password.

      

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

EDIT

I updated the properties of the scheduled task, which is not a problem. The problem is with the username and password in the batch file. The weird thing is, if I enter interactive mode and double click on the executable, everything works fine.

The last time the job started it, a semaphore timeout error occurred. I've never seen this particular error before, but it looks like it was actually logged and was trying to copy files when it did.

EDIT

I have revised my code to keep it as simple as possible. I am using a batch file to map the drive and then using code to transfer the files. I still run into the same question - it works fine when I double click on the batch file, but as soon as I drop the Scheduler into the image, it throws a "Bad username or wrong password" error.

Sometimes when I try to run a file by double clicking on it, I get the message "Part of the path could not be found." This tells me that disk mapping did work, but something failed when it tried to copy. (Double-click testing works fine in most cases)

+2


source to share


4 answers


The username and password associated with the job when it was created are no longer valid or have been changed. This usually happens when creating a task and forgets to select the option not to store the password. When your password expires, you will face this problem every time you have to reset your password. Be sure to do as in the image: enter image description here



+6


source


It looks like the username and / or password associated with the scheduled task are no longer correct. The batch file is most likely OK, you just need to change the properties of the scheduled task.



+1


source


I ran into something similar while testing a new powershell script we wrote to create a scheduled task to back up to one or more network locations. I had to go through several iterations and when I reduced from two LANs to one, the scheduled task stopped working, with individual steps in the script being called giving errors "Login failed: unknown username or bad password", although when I copied arguments and ran them from the command line, they worked.

After reading this question and Tim's comment, I tried to delete the scheduled task and recreate it. After that, everything worked out. I would agree that the scheduled job is most likely caching something.

0


source


From: https://danblee.com/log-on-as-batch-job-rights-for-task-scheduler/

Go to the start menu. Run. Type secpol.msc and press Enter. The Local Security Policy Manager opens. Go to Security Settings - Local Policies - User Rights Assignment Node. Double-click Log on as Batch Job on the right side. Click Add User or Group ... Select a user and click OK.

0


source







All Articles