I don’t know if any of you are familiar with the Windows Command line interpreter (Command/Command Prompt) or not. The average person probably hasn’t ever heard of it, not to mention what it does or how to use it for that matter.
It basically allows you to enter commands that range from very simple to more complex. You can really do a lot of things with it, and it does come in handy occasionally when your computer is not being nice.
Some of my first computer system programming work involved the Command Prompt/MS-DOS Prompt.
One of the major drawbacks to using the Windows command line is it can be time-consuming. You have to type one line at a time and hit enter, which is fine if you want to do something simple. However, if you need to enter multiple commands it can be tedious.
If you happen to use several lines of commands on a regular basis what you can do is create a .bat (batch file) with multiple lines all in one file. When you run a .bat file it is read and processed line-by-line. So this can save a lot of time for repetitive tasks.
That’s great right, but I don’t see how that can help me?
Here is an example:
Every day I turn on my computer and do the same set of things at the start of my day. This simply involves the following:
- Starting up Firefox (web browser)
- Opening several websites (3-5)
- Opening a Notepad .txt file
- Starting the Windows Task Manager
So that is 6 to 8 things I do every day before I even get started. I know that probably doesn’t seem like a lot, but rather than start and open each, one by one, I slap them all in a .bat file, do a quick double click on the .bat file and all of them start up. This doesn’t save me a significant amount of time, but it does help, and it simplifies everything into one. Any time I can combine 6 to 8 tasks into one, then I am all for it.
How do I do that?
I open a new Windows Notepad document and place one command per line. Then, save it with a .bat extenstion to my desktop. From then on all I have to do is double click the .bat file on my desktop at the start of each day and I am good to go.
Here is what my file looks like:
“C:\Program Files (x86)\Mozilla Firefox\firefox.exe”
PING 192.0.2.2 -n 1 -w 6000 >NUL
start notepad “C:\Users\My-Account-Name\Desktop\some-notepad-document.txt”
So I would put that in a new notepad file and save it as say: start-daily.bat to my desktop.
I would then find a gear-looking icon on my desktop called start-daily that I can double click on.
I should also mention that if you need to make changes to a .bat file all you have to do is right click on the file and select edit, which will automatically open it in notepad for editing instead of executing it.
So what happens when this .bat file is double-clicked on (executed) is:
1. Firefox.exe starts up
2. The ping line tells it to wait 6 seconds before continuing on to the next line. The 6000 part is milliseconds (6 seconds). I do this to allow enough time for Firefox to fully start up before opening the links. Otherwise, what happens is you end up opening the links in new windows rather than new tabs.
3. Dialme.com opens in a new tab.
4. Gmail.com opens in a new tab.
5. Facebook.com opens in a new tab.
6. Twitter.com opens in a new tab.
7. bbc.co.uk opens in a new tab.
8. Some-notepad-document.txt opens in Windows notepad.
9. Finally, the Windows Taskmanger starts up.
This whole process happens fairly fast and you can adjust the ping 6000 milliseconds part as need be. Like I mentioned you just need to allow enough time for your browser to start up before opening additional links, otherwise you end up opening new windows instead of tabs.
You could easily open Internet Explorer or Chrome instead of Firefox. Maybe you have other programs you start at the beginning of your day, or other document file types. There are tons of possibilities if you think about it.
It is certainly possible to get much more complex than this as well.
For me this saves time and adds automation even if it is only 6 to 8 tasks.
I just thought I would pass this one along to everyone.
Word of caution about .bat files
One thing I should add about the Windows Command Line and .bat files is make sure you know what they actually do. If you are not sure don’t use it. There are plenty of not so nice sites out there that have posted commands and .bat files that will mess up your system, erase your hard drive, or do massive destruction to your computer. All it takes is some knot head telling you that it will do something nice, but turns out it will wipe your c:\ drive all with a couple lines of code or by double-clicking a batch file so be careful.