Getting a Substring Out of Batch

One of my friends, Andrew from Vancouver, sent me this extremely useful tip about how to grab a sub-string via BATCH.
<snip>

here’s a CMD shell tip that works in W2K, WXP, and W2K3.

There is a BASIC MIDSTR function equivalent in batch files… use this syntax as a modifer:

~:start,end

e.g.

set foo=\\servername
@echo unretouched [%foo%]
@echo modified [%foo:~2,99%]

will output:

unretouched [\\servername]
modified [...]

Audit your computer’s network settings

If you’ve ever tried to audit the speed and duplex settings of NICs in a windows environment, I’ll bet you’ve been frustrated by the fact that you can’t seem to find the answer to this anywhere in the registry or WMI, etc. etc. Yet you know it has to be recorded somewhere because the little [...]

Audit your computer’s network settings

If you’ve ever tried to audit the speed and duplex settings of NICs in a windows environment, I’ll bet you’ve been frustrated by the fact that you can’t seem to find the answer to this anywhere in the registry or WMI, etc. etc. Yet you know it has to be recorded somewhere because the little [...]

For Better, and for MUCH Better - using a FOR Loop to run the same command against multiple computers

If you administer more than, say, 3 computers in your network, you’ve probably wanted to perform some operation against all of them in quick fashion. For example, you may get a frantic call some morning from your IT manager that goes something like this:
IT Manager: “I just got a call from my friend Bob, [...]

How to insert a carriage return with batch

Sometimes the quickest way to accomplish something in Windows is with a simple batch file. The best example would be when you want to run a command and append the contents of it to a text file for later perusal. Occasionally, I’ve had a desire to run multiple commands and append them to [...]

How to delete disabled users in bulk from Active Directory

Using the adfind and admod command line utilities, it is easy to delete disabled users in bulk from your Active Directory. Read on for an example of how to do this.

Shortening your regular expression match in perl

Normally, when you pattern match using a regular expression in Perl, your expression will match as much as possible.
For example,
$match = "hello to you world what in the world were you thinking";
$match =~ /hello.*world/;
$match is now "hello to you world what in the world"
If you want to make this match the least amount and still [...]

Generate a list of the servers in your Active Directory (from cmd line)

Want to quickly generate a list of all of the servers located in your Active Directory? Get adfind.exe from www.joeware.net, and then from a cmd prompt, do:
adfind -config -f “objectclass=server” -nodn name -csv -csvnoq > serverList.ini
This will create a list of all servers in your environment, and put them in a file called serverList.ini. [...]

Passing an array reference in perl

In perl, when you declare a variable and assign it a value, and then later pass that variable into a function, the function is getting a copy of the variable, manipulating it, and then passing back some result. This may be fine for most operations, but if you are operating on a large array of [...]