Welcome to MSDN Blogs Sign in | Join | Help

June 2005 - Posts

It's pretty easy to deal with up to 9 arguments in batch through built-in variables %1 through %9 . For example: echoargs.cmd @echo off echo %1 echo %2 echo %3 echo %4 echo %5 echo %6 echo %7 echo %8 echo %9 If you feed this A B C D E F G H I, you'll Read More...
1 Comments
Filed under:
Earlier , I used >nul 2>&1 to suppress the output of a command, and the question was brought up as to why this was "better" than just >nul . To understand what's going on, you need to know that there are two streams of output from any given Read More...
2 Comments
Filed under:
I spend a lot of time in a CMD window. I mean a lot of time. Often I'd like to open a web page, but opening up Internet Explorer and navigating my way to the page in question is such a chore. I'm lazy. I don't like mouse-clicks. Enter the quicky batch Read More...
Here's something I'd never noticed until today, when I discovered it quite by accident. In general, to run a program in a different directory, you specify the path with backslashes, such as C:\WINDOWS\system32\notepad.exe . This should be no surprise. Read More...
3 Comments
Filed under:
There's a fine line between an assumption and a bug. If the assumptions are spelled out ahead of time, then it's not a bug if the script does what's expected, taking the assumptions into consideration. Having disclaimed that, then, here are some of the Read More...
0 Comments
Filed under:
In the previous post, there was a fair amount of code and basically no explanation... Here's how it breaks down: Naïve method: set FILENAME=basename-%RANDOM% CMD has a built-in variable called %RANDOM% . Simply put, it returns a random value between 0 Read More...
1 Comments
Filed under:
Someone today was asking how to create unique filenames. They had some process which ran in a loop, and they wanted to direct the output of that process to a file, but rather than always overwriting the same file, they wanted to keep history using distinctive Read More...
0 Comments
Filed under:
There are a couple of scripts that have been with me since the beginning of time. I don't use them that much anymore, but they occasionally come in handy. I'm always pleasantly surprised to find that I still have them when I need them. One makes files Read More...
2 Comments
Filed under:
It occurs to me that my mistypings of 'notepad' and 'exit' are probably more the result of muscle-memory since I type those so often. The mistakes I make are due to one hand hitting its letter before the other (correct) hand hitting its. Just a thought Read More...
2 Comments
Filed under:
Some scripts are complex and do lots of cool stuff. Others are simple and save a bunch of time. I have a couple of scripts which prove to be so useful that I don't know when I'm using them anymore. I tend to type faster than I think (or get my fingers Read More...
0 Comments
Filed under:
In the beginning, there was DOS. And DOS had batch files - little scripts that ended in .BAT. So, when I started writing and collecting a few useful ones, I created a directory, C:\BELFRY in which to keep my .BATs. Get it? Bats? Belfrey? Oh, never mind... Read More...
There are a couple of books that I have found to be particularly useful. Whether you're a beginner or you have your black belt in script-fu, you'll find them to be excellent references. Windows NT Shell Scripting is an excellent place to start. Tim Hill Read More...
0 Comments
Filed under:
The Windows 2003 Resource Kit has a number of indispensible tools. For scripting, the two handiest are sleep and robocopy. Grab these - you'll need them. Read More...
0 Comments
Filed under:
I wonder how many first posts in blogs are given the title "First post!". I'm guessing a good 75%. So the idea behind this particular blog is this: anyone can write a script (even you!), but it takes work to write a good * script. Here you'll learn how Read More...
 
Page view tracker