Solved

Schedule and Purge

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

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Batch to Restart Remote Computers 4 102
network copying issue 4 71
Batch file or script with password 22 92
Exclude all *.dat files from a 7z.exe command line 13 29
Using dates in 'DOS' batch files has always been tricky as it has no built in ways of extracting date information.  There are many tricks using string manipulation to pull out parts of the %date% variable or output of the date /t command but these r…
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…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

733 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