Solved

Schedule and Purge

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

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 69

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 69

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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

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

The following is a collection of cases for strange behaviour when using advanced techniques in DOS batch files. You should have some basic experience in batch "programming", as I'm assuming some knowledge and not further explain the basics. For some…
VALIDATING DATES One method of validating dates is to jam the date into the DATE command and see if it accepts it by examining the system's errorlevel value. A non-zero result indicates failure. A typical example might look something like the fol…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

773 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