Solved

Schedule and Purge

Posted on 2009-07-13
5
371 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
5 Comments
 
LVL 70

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 70

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 70

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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…
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…
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …

688 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