Image 1 of 9
In this The Right Tool for the Job? post, Joshua Hoskins explains how he uses batch files and the Windows Task Scheduler to save time and effort when performing repetitive admin tasks.
Flush DNS Script
Shown here in Notepad, the Flush DNS Script will flush your DNS cache using the IPCONFIG command.
Clear Bad Mail Script
This script will delete the contents of your IIS bad mail folder. The script uses the DEL command along with the quiet switch (/q) to prevent prompting for deletion.
When run, this reboots the host computer. The script uses two switches, /r which causes the system to reboot and not shutdown and /f which forces running applications to close. You can also use the shutdown command to shutdown remote computers.
This script will stop and restart your SMTP service. Used with Windows Task Scheduler, you can easily restart services on a regular schedule. The script uses the NET command–an extremly useful Windows command line command.
Command Line Service Name
This screenshot shows the service properties for the World Wide Web Publishing Service. From this screen you can see the actual service name (W3SVC). You use this service name when you reference a service from the command line. For example, when stopping and restarting the SMTP service as in the SMTP Service Reset Script.
Scheduled Task Initial Schedule
From this wizard screen, you set your initial schedule for a job. You can apply multiple schedules from the Advanced dialog box.
Scheduled Task Authentication
You must enter authentication information for the task to run. Your scheduled task will run as the user you specify here. You must verify that the user account has sufficient permissions to complete the tasks in your batch file. If you are running commands against a remote machine (such as shutdown), this account must also have appropriate permissions on the remote machine.
Scheduled Task Advanced Screen
From the Advanced Properties first screen, you can change your authentication, alter where your batch file is located, enable or disable the task, and set the task to only run if the system running the task is logged in.
Scheduled Task Advanced Screen 2
This is where many of the more advanced options for your task are. You can set the computer to automatically stop the task after a certain run time, only start or stop the task if the computer is idle, and configure options for the task based on your power settings.