scheduling a Batch file with parameters using the AT command

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
schmintan
Posts: 3
Joined: 23 Apr 2012 09:52

scheduling a Batch file with parameters using the AT command

#1 Post by schmintan » 02 May 2012 09:40

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?

Fawers
Posts: 187
Joined: 08 Apr 2012 17:11
Contact:

Re: scheduling a Batch file with parameters using the AT com

#2 Post by Fawers » 02 May 2012 10:03

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?

Squashman
Expert
Posts: 4488
Joined: 23 Dec 2011 13:59

Re: scheduling a Batch file with parameters using the AT com

#3 Post by Squashman » 02 May 2012 10:12

Why aren't you hard coding the path to the batch file?

I would also look at using SCHTASKS instead of AT.

schmintan
Posts: 3
Joined: 23 Apr 2012 09:52

Re: scheduling a Batch file with parameters using the AT com

#4 Post by schmintan » 02 May 2012 10:22

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!

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: scheduling a Batch file with parameters using the AT com

#5 Post by foxidrive » 02 May 2012 10:29

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.

Squashman
Expert
Posts: 4488
Joined: 23 Dec 2011 13:59

Re: scheduling a Batch file with parameters using the AT com

#6 Post by Squashman » 02 May 2012 11:09

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.

Fawers
Posts: 187
Joined: 08 Apr 2012 17:11
Contact:

Re: scheduling a Batch file with parameters using the AT com

#7 Post by Fawers » 02 May 2012 11:10

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

Post Reply