Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: NT
Expertise: Beginner
Mar 20, 2000

Schedule a Batch File

Question:
I need to schedule a batch file to automatically run at night. I have tried every variation of the "AT" command from a command line on the Windows NT Server (NT4) and it will not execute the batch file.

If I run the batch file manually from the command line, everything works just fine. What I entered for the "AT" command was: at 7:30 /next:Th cmd /c c:\batchfilename.cmd

I've tried with and without quotation marks around the path & file name AND tried including the cmd portion inside the quotation marks AND using cmd.exe AND every other variation I could think of. Nothing works. What is the correct format? I've even gone to the Microsoft site and tried what they state is the proper syntax—it didn't work
begin batch file:
@echo off

rem delete any current share using drive letter E
net use e: /delete

rem create a share to the data
net use e: \\scsm1\d$ password /user:domain\account

rem jump to the folder the data will be xcopied to
h:
cd\scsm1.bak

rem delete all existing files in the folder
erase *.* /f/q/s

rem copy all files in all subdirectories even if errors
xcopy e:\public /s/e/v/r/h/q/c
end batch file
Any help would be greatly appreciated.

Answer:
Yep, I know exactly what is happening. From the command line, the batch file is running under your security account—from the AT schedule command, it is running in the context of the System Account. The System account has 100% rights on the local machine, and 0% rights to use network services. So, when you are trying to work with commands that are going through the network director, it will fail.

Try running the Schedule Service under your logon and see if it doesn't magically work.

DevX Pro
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date