April 15, 2016

Adding a unique per run environment variable to a batch file.

Let’s say you have a batch file, and that batch file needs to write some temporary files. Sure, you’d rather avoid it, but in this case, you don’t have a choice, and you have to write the temporary file. While you could just hard code a file name, to reduce the likelihood that your batch will clobber an existing file, you can create a unique identifier at runtime that you’ll use throughout the script. ... Read more

February 23, 2016

Make a zip that is named with the current date

In the Windows command prompt, using 7zip, make a zip archive that is named with the current date. You can use partial expansion of environment variables to achieve similar results in a number of places. 7z a %date:~-4%%date:~4,-8%%date:~7,-5%.zip archive

February 23, 2016

Prips using for - print all of the IP addresses in a range

Prips is a great tool for printing the IP addresses in a range. Sometimes, you’re on a platform that doesn’t support that, like Windows. The good news is that you can approximate some of the features of prips using only the Windows for command. for /L %d in (0,1,255) do for /L %c in (1,1,64) do for %b in (100,101,102) do echo 10.%b.%c.%d >>ip.txt This writes a text file that contains 10. ... Read more

January 23, 2016

Get a last reboot report for a list of domain computers

Environment: Requires a command prompt running with domain admin rights, GNU sed, GNU grep, and Microsoft Sysinternals psexec. All tools are assumed to be located in directories included in the %PATH% environment variable. Starting with a directory containing a subdirectory called “data” and a text file containing a list of computers. The text file contains one computer per line (computers.txt). The “reboot time” reported is the start time of the server service. ... Read more