mjhenry
mjhenry

Reputation: 53

Batch file won't run as scheduled task

I have a batch file that creates a copy of an Access database as a backup and stores it on the network with a date stamp suffixed to the file name. This batch file runs fine on its own and also as a scheduled task while I am logged into the server (Windows server 2008 R2). But despite trying many things I cannot get the scheduled task to run when I am not logged into the server. I have tried configuring the scheduled task properties to run with the highest privileges, tried switching the settings of "run whether user is logged in or not" - and sore password options, tried amending the "Actions" tab by putting the path in the "Start In" parameter and only the batch file name in the "Program" parameter but still nothing works. What am I doing wrong here?

Upvotes: 1

Views: 1098

Answers (2)

mjhenry
mjhenry

Reputation: 53

I have this resolved - you live and learn as they say - and I learned something about batch scripting that I wasn't aware of. Thank you TripeHound for assisting me in pinpointing that it was a network issue.

My batch file was copying the Access database to my company's "I:\" drive, but I learned that while the user is NOT logged into the server the "I:\" drive is NOT recognized and so I changed the I:\ part to the actual server name path, i.e "\the_server\the_drive$" and then it all worked

Upvotes: 1

omal bose
omal bose

Reputation: 31

Check with following script replace the the folder name with your network folder name. Disable the "Run only if logged on option" and store the password using "Set password" option.

@echo off set folderName=D:\omal\BackupProjectDaily\%date:~7,2%%date:~4,2%%date:~10,4% echo %folderName% if not exist %folderName% md %folderName% copy 1.txt %folderName%\1-%date:~7,2%%date:~4,2%%date:~-4%.txt pause

exit

Upvotes: 0

Related Questions