I have a batch file that takes a filename and location and renames the file with todays date and current time.
I need to schedule this to run at a specified time
I tried the following but no success:
C:\Windows\System32\at.exe 16:50 c:\windows\system32\cmd.exe /c %Path%\Rename_File.bat %Filename% %FileLocation%
To simplify i removed the parameters and am running the following:
C:\Windows\System32\at.exe 16:50 c:\windows\system32\cmd.exe /c %Path%\Rename_File.bat
when i run this i get the error "The directory name is invalid".
It seems that the AT command is great for exe's but rubbish for bat or cmd files. can anyone advise how i can schedule the running of my bat file?
scheduling a Batch file with parameters using the AT command
Moderator: DosItHelp
Re: scheduling a Batch file with parameters using the AT com
The PATH variable expands to 2+ locations on your computer. On mine, it expands to 8 different folders. That's why you're gettint such an error message.
Besides, if any part of your desired path contains spaces, then you need to enclose it all in "quotes".
What is your required (full) path?
Besides, if any part of your desired path contains spaces, then you need to enclose it all in "quotes".
What is your required (full) path?
Re: scheduling a Batch file with parameters using the AT com
Why aren't you hard coding the path to the batch file?
I would also look at using SCHTASKS instead of AT.
I would also look at using SCHTASKS instead of AT.
Re: scheduling a Batch file with parameters using the AT com
im using a variable for the path as i use the path a few times prior to this in my script:
SET Path=E:\Directory\Files
There are no spaces in the path.
Il see if schtasks can do whats required. Thanks!
SET Path=E:\Directory\Files
There are no spaces in the path.
Il see if schtasks can do whats required. Thanks!
Re: scheduling a Batch file with parameters using the AT com
schmintan wrote:im using a variable for the path as i use the path a few times prior to this in my script:
SET Path=E:\Directory\Files
PATH is a system variable and will be reset every time you start a new prompt. *never* use PATH for your variable name or you will get unexpected results.
Re: scheduling a Batch file with parameters using the AT com
schmintan wrote:im using a variable for the path as i use the path a few times prior to this in my script:
SET Path=E:\Directory\Files
There are no spaces in the path.
Il see if schtasks can do whats required. Thanks!
I wasn't talking about what was in your batch file, I was talking about the directory path to your batch file which you are trying to use to schedule your task.
Re: scheduling a Batch file with parameters using the AT com
You might want to try this:
Code: Select all
set "file=DRIVELETTER:\path\to\your\file\FILENAME.fileXtension"
AT 16:50 cmd /c "E:\Directory\Files\Rename_File.bat" "%file%"
foxidrive wrote:*never* use PATH for your variable name