Solved

Schedule and Purge

Posted on 2009-07-13
5
340 Views
Last Modified: 2012-05-07
Dear Experts,

I need help creating a Bat script I can send to someone externally which will create a Windows Schedule to purge the Windows Temp folder daily and create a list of what has been deleted.

I know how to purge/del when I'm in DOS, but not create a bat that makes a schedule
0
Comment
Question by:jackoltd
  • 3
5 Comments
 
LVL 68

Expert Comment

by:Qlemo
ID: 24839183
The batch file itself will not make the schedule. You need two "commands": One for creating the Scheduled Task, and one for deleting (being called). The latter is a single batch file, you just put all your delete commands in there.
The former is done with schtasks /create. Just type the following command in cmd.exe to get several pages of help:
schtasks /create /? | more

0
 
LVL 1

Accepted Solution

by:
NicolasQuenard earned 250 total points
ID: 24839283
you can schedule tasks with the AT command. Just try:

C:\WINDOWS\system32>at /?

The AT command schedules commands and programs to run on a computer at
a specified time and date. The Schedule service must be running to use
the AT command.

AT [\\computername] [ [id] [/DELETE] | /DELETE [/YES]]
AT [\\computername] time [/INTERACTIVE]
    [ /EVERY:date[,...] | /NEXT:date[,...]] "command"

\\computername     Specifies a remote computer. Commands are scheduled on the
                   local computer if this parameter is omitted.
id                 Is an identification number assigned to a scheduled
                   command.
/delete            Cancels a scheduled command. If id is omitted, all the
                   scheduled commands on the computer are canceled.
/yes               Used with cancel all jobs command when no further
                   confirmation is desired.
time               Specifies the time when command is to run.
/interactive       Allows the job to interact with the desktop of the user
                   who is logged on at the time the job runs.
/every:date[,...]  Runs the command on each specified day(s) of the week or
                   month. If date is omitted, the current day of the month
                   is assumed.
/next:date[,...]   Runs the specified command on the next occurrence of the
                   day (for example, next Thursday).  If date is omitted, the
                   current day of the month is assumed.
"command"          Is the Windows NT command, or batch program to be run.
0
 
LVL 68

Expert Comment

by:Qlemo
ID: 24839313
at does not allow for many settings schtasks does. And all AT jobs run under a single service account, which has to be set up first. schtasks creates tasks with a different user, or the logged in one. at is getting depricated.
0
 

Author Comment

by:jackoltd
ID: 25061884
Seems one of the staff here has created 2x BAT files to do this.. if anyone would like to see..
0
 
LVL 68

Assisted Solution

by:Qlemo
Qlemo earned 250 total points
ID: 25061951
You can post them here, accept your own answer, giving a point share if you like.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

One of my most closely kept secrets is revealed in this discussion How to output text on the same line This question was recently posted in EE by Simon336697 (http://www.experts-exchange.com/Programming/Languages/Scripting/Shell/Batch/Q_2459…
YESTERDAY YESTERDAY.BAT is inspired by a previous article I wrote entitled: TOMORROW.BAT (http://www.experts-exchange.com/OS/Microsoft_Operating_Systems/MS_DOS/A_4196-Advanced-Batch-File-Programming-TOMORROW-BAT.html). The crux of this batch f…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now