A batch file on Windows is a .bat file that contains one or more commands. You can execute .bat files by double-clicking, via the command prompt, or even as an "executable" in a scheduled task. Their power as a timesaver is in their ability to encapsulate common functionality so that you don't have to click a lot or remember a lot. This is predicated on the idea that every mouse movement/click is itself a time waster.
Common Example How do you start/stop/cycle ColdFusion? Certainly one way to do it is through the Windows Services panel. Let's count the mouse movements:
- Start Menu
- Control Panel
- Administrative Tools
- Scroll to Macromedia JRun CFusion Server
- Click the "Stop" or "Start" button up top
And that's just for one action. Multiply that by the other services you frequently cycle. SQLServer? MySQL?
Bat Files for Scenario Above
NET STOP "Macromedia JRun CFusion Server" NET STOP "Macromedia JRun Admin Server"
NET START "Macromedia JRun CFusion Server" NET START "Macromedia JRun Admin Server"
NET STOP "Macromedia JRun Admin Server"
NET STOP "Macromedia JRun CFusion Server"
NET START "Macromedia JRun Admin Server" NET START "Macromedia JRun CFusion Server"
Where to store them? Obviously, you don't want to go putting dozens of bat files on your desktop. So where to put them? I keep mine in a directory, and then add a shortcut to that directory into my windows taskbar by following these steps:
- Right click in taskbar
- select "Toolbars"
- select "New Toolbar"
- Navigate to the directory where your bat files live. Click "OK" through to the end.
From there, you can access your bat files from that new toolbar right from your windows taskbar. The nice thing about this approach is that you don't need to double-click on the file... just single click. Here's a screenshot of what it might look like:
Isn't there a better way?Yup.... Stay tuned for the next Timesaver!