Monday, May 22. 2006

This goes along with the %0 trick I mentioned previously but if you are still using DOS style scripts for logons, whether to support older clients, or to keep an old setup around for historical purposes, make sure to call out the executable with a complete pathname and/or at least the correct extension.

This might seem like a really minor point but everytime the OS has extra "work" over a starved connection, performance will stall due to directory lookups and such.

So, instead of calling:
notepad newfile.txt

Use:
%windir%\notepad.exe newfile.txt

A side effect of stating 'notepad.exe' instead of 'notepad' is that the command prompt won't go looking for notepad.bat, notepad.com, or notepad.cmd, across the wire.

This makes a difference because any file extension mentioned in %PATHEXT% is cycled through until it finds a match.

This also helps in the case where a virus hijacks 'notepad.bat' somewhere in the path and you end up not running the intended executable. It is a bit of a security 'fixup' if you want to think of it that way.

Some might view this as overkill but when you are stuck logging into a domain over a cell phone data connection, you will thank me later. Ideally, you would want to convert your scripts to a VBScript or a PowerShell script, but that isn't always possible or feasible.