Jump to content

Recommended Posts

Posted

I'd like to create an executable that I can send to friends and family that will automate computer maintenance such as Defrag, Disk cleanup, and Disk Check. I'd like it to be compatible with XP and 7 and possibly through Windows Task Scheduler so it'll be automated for a period of time. I found the steps for each at http://www.microsoft.com/athome/setup/maintenance.aspx but not sure how to turn these steps into an executable like a .bat? Any suggestions where I can learn to do this?

Thanks, Jerf.

Posted (edited)

Um, just throw everything in a bat file, and use the built in task scheduler via command line with "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.

You could also probably get away with creating them in the GUI via Task Scheduler on your own machine, and then EXPORTING them as XML files, then IMPORTING them on the other machines you want them to run on.

Edited by digip
Posted

Ok so I found http://ss64.com/nt/ very helpful when programing .bat files. I got the disk clean up (sorta) done. I'd like it to be more automated and not ask which files to clean up but at least I got it running. Now for the Defrag then the Disk Checking.

Posted

Ok so I found http://ss64.com/nt/ very helpful when programing .bat files. I got the disk clean up (sorta) done. I'd like it to be more automated and not ask which files to clean up but at least I got it running. Now for the Defrag then the Disk Checking.

I've made a bit of progress. I came up with: "CleanMgr /d C:\" and "defrag /c /h".

However it seems the Defrag command can only be run by the Admin? How would I start the .bat with Admin rights?

Also I seem to be having trouble creating the .bat with more than one command in it. How do I execute a list of commands in one .bat file?

Posted

What I would do, is use the bat to create the automated tasks to run on a schedule, something that should allow them to run with no intervention. Windows 7 should have a task in there already though. Since Vista came out, microsoft has an automatic defrag every wednesday I think at 1am or something and is enabled by default install. XP does not however do this automatically, but a scheduled task can be done for it as well.

If you want a program to run as administrator, just right click it and "run as" administrator. Same goes for shortcuts and batch files. Easiest method though, is login as admin, create the scheduled tasks, and they should then run under any user unattended.

Posted

I'm trying to set something up for say my grandmother half way across the country. Something I can email her and it'll run, setting up the tasks, without her having to figure anything out. Have it all automated and simple for her. So I'll do the work here and she won't have to.

So in order to use the bat to "create the automated tasks" I need to use that "AT" command in my bat? Also how do I assign more than one command to the bat?

Posted

I'm trying to set something up for say my grandmother half way across the country. Something I can email her and it'll run, setting up the tasks, without her having to figure anything out. Have it all automated and simple for her. So I'll do the work here and she won't have to.

So in order to use the bat to "create the automated tasks" I need to use that "AT" command in my bat? Also how do I assign more than one command to the bat?

Well, it might be easier to just remote in(rdp, vnc, team viewe, etc), set up the scheduled tasks for her in the GUI using scheduled tasks, and be done with it.

As for commands in a bat script, you can just put all the commands on their own lines and they should run so long as the programs you are running, have command line versions with no interaction required. Defrag for instance, will run from the command line, but other programs, might only run in a GUI and require her to reply to them by clicking OK or some other dialog box. Then their is the Windows Vista and 7 UAC issues, which might prompt her when things get launched. That shouldn't be an issue if created under an admin account.

Posted

Didn't even think about remoting in. Thanks for the idea!

Might mess around with this a bit more. Maybe a macro? Don't know much about them but the way I understand it, it would follow my exact mouse clicks and keyboard entries? So something like: Start > Run > Task Scheduler > Defrag > 1st of every month. Hmm I'll have to look into it. Was trying to take care of all my family and friends without having to log into each individually, just send a mass email and be done.

Thanks for your help digip.

Posted

If you need an automatic disk defragger, can I recommend SmartDefrag. I've been using it on my computer for a very long time, it does all the work by itself no user interaction required. It automatically determines if your hard disk needs DE-fragmentation or not.

Posted

Try the export feature of the Task Scheduler though. Not sure how XP handles that, but for Vista and 7, should be the same. XP would require a bat script with the AT command, as I don't remember if it has import/export features, and the paths and setup would probably be different than Vista/7 anyway.

http://msdn.microsoft.com/en-us/library/bb756979.aspx

Starting via command line in Vista/7 - http://technet.microsoft.com/en-us/library/cc748993.aspx

Starting in XP via command line - http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/schtasks.mspx?mfr=true

Posted

Either way, its your choice you can go with a batch script or a third party software.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...