Freeware Windows command-line, (DOS style), utilities
Unas cuantas utilidades command-line, para los nostálgicos…
This program, weighing in at 8K, pings a specified host every 55 seconds, and displays the status in the System Tray. I wrote it because I work on a system where the remote end of the connection only comes up periodically, and then only stays up while there is activity on the line. I can leave vsp running in the tray and wait for the green light, knowing that the ping activity is enough to keep the link open if I’m away from my machine when the link comes up.
There are plenty of programs that offer this functionality and more, but I didn’t want some 1-2M monster to perform this simple task.
This is a quick and dirty program for changing screen mode, (resolution, color depth, etc.), and then optionally running a specified program. It is useful for running apps/games that only run in a specific screen mode. For example, I run this program from a shortcut to start WinTV in 640×480 mode, since WinTV’s “full-screen” option will only work at this resolution, (due to limitations of my video driver).
Run the program directly, (with no parameters), for a list of screen modes supported by your display. Specify a display mode as a parameter to change the display mode. You can also specify the name of a program to run after changing the display.
C:\>scrnmode 11 “C:\Program Files\WinTV\wintv.exe”
This sets the display mode to 11, then runs “wintv.exe”. If the program to run also takes parameters, include them as a third parameter to scrnmode. (Enclose multiple parameters in quotes if necessary.) To reset the display mode to the original setting, run the program with “reset” as a parameter instead of a display number.
WARNING!: Changing display modes dynamically can hang certain Windows configurations. Avoid using this program any time you have important unsaved data in open applications. Please do not blame, (or flame), me if things get messed up.
RMMINUSR deletes files recursively, (that is, it searches through sub-folders). For example:
This will remove all files on C: that have a .tmp extension, (assuming its run in the “root” directory). This utility is useful for clearing out log files and temporary files that typically clutter up the root drive on a Windows machine. Note that this utility does not give any delete confirmation messages – Use with care! Unix users should recognise where I came up with the name.
DOFF prints a formatted date and time, with an optional date offset, (e.g -1 prints yesterday’s date, +1 prints tomorrow’s date). To view all the options available, execute “doff -h”. I typically use this utility for renaming log files so that they include a timestamp, (see the third example below). This code should compile under Unix/Linux, as well as DOS.
With no parameters the output is the current date/time in the following format: yyyymmddhhmiss
In the above example a date format specification is given.
for /f “tokens=1-3 delims=/ ” %%a in (‘doff mm/dd/yyyy -1’) do (
rename httpd-access.log httpd-access-%yyyy%%mm%%dd%.log
The sample batch file above shows a neat way to rename a log file based on yesterday’s date. The “for” command executes doff to print yesterday’s date, (the “-1” parameter specifies yesterday), then extracts each component of the date into DOS batch file variables. The “rename” command renames “httpd-access.log” to “httpd-access-[yesterday’s date].log”
STOPWATCH can be used to calculate the elapsed time, (in seconds), in a batch file. It does this by redirecting the current time out to a file when the “start” command is given, and then reading that time back in when a “stop” command is given. For example:
C:\>stopwatch start > timestamp.txt
… other batch commands here …
C:\>stopwatch stop < timestamp.txt
Note that the output from the stop command can be piped or redirected to a program or file if required, and multiple “stop” commands can be executed to get intermediate timestamps. If you want to save the output of the “stopwatch stop” command to a variable, DOS/Windows doesn’t make things easy for you. Here’s an example that includes an ugly workaround to get the elapsed time into a variable called “elapsed_time”:
stopwatch start > timestamp.txt
… other batch commands here …
stopwatch stop < timestamp.txt > elapsed.txt
for /F %%a in (‘type elapsed.txt’) do set /a elapsed_time=%%a
MEMLOG logs Windows memory usage. By default, it checks every 5 seconds though this can be changed by specifying the interval, (in milliseconds), on the command line:
The above command checks memory every second. Specify an interval of 0 to check memory one time only and then exit. The output is:
Date,Time,Free Physical,Free Page,Free Virtual,Total Physical,Total Page,Total Virtual
Memory figures are in bytes.
To save the output, redirect it to a file:
C:\>memlog 1000 > mem.csv
Note: Excel will recognize a “.csv” extension as a comma-separated file and will load it directly in spreadsheet format.