Anoop
Anoop

Reputation: 2101

Scheduling job on windows server 2008

I have a file located in c:\sample\file.exe. Now i want to execute file.exe every night.How can i achive this using batch file?

Please help me out

Upvotes: 0

Views: 2407

Answers (2)

Sunil Agarwal
Sunil Agarwal

Reputation: 4277

Save this command in batch file and execute it.

%SYSTEMDRIVE% SCHTASKS.EXE /CREATE /SC DAILY /TN "Name of task" /ST 12:00:00 /TR "c:\sample\file.exe" /RU ""

Upvotes: 1

paxdiablo
paxdiablo

Reputation: 882108

Under the Control Panel, there's a applet called Scheduled Tasks. This is usually how you set up, um, what was it again, yes, that's it, scheduled tasks :-)

If you really want to do this from a batch file rather than a nice GUI (e.g., you're doing it as a part of some silent install), you use either at or schtasks. See here for details, or use this as a template:

schtasks
    /create                     # Create a task.
    /tn SampleFile              # This is its name.
    /tr c:\sample\file.exe      # This is the file to run.
    /sc daily                   # Every day.
    /st 23:55                   # At five minutes to midnight.
    /ru User                    # User name to use.
    /rp Password                # Password of that user.

See the afore-mentioned page for even more options.

Upvotes: 2

Related Questions