Solved

Schedule and Purge

Posted on 2009-07-13
5
345 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Creating script that will zip file every 15 days 8 82
MailSend Attachments 41 139
Build VS2015 project in bat command 3 80
how to  skip files that were already there? 3 38
TOMORROW TOMORROW.BAT is inspired by a question I get asked over and over again; that is, "How can I use batch file commands to obtain tomorrow's date?" The crux of this batch file revolves around the XCOPY command - a technique I discovered w…
Being a system administrator some time we require to do things remotely, one of them is installing software. Here I am going to tell you how to install software through wmic (Windows management instrument console). I am not at all saying that this i…
This is a video describing the growing solar energy use in Utah. This is a topic that greatly interests me and so I decided to produce a video about it.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

914 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

22 Experts available now in Live!

Get 1:1 Help Now