4NT, my way to start applications

27 Juli 2006

In his podcast 'Start-Run-Replacements' Scott Hanselman obmitted 4NT, which is what I use to start my applications since NT 3.5 when we still had non-hierarchical program groups in Program Manager to manage our apps. With NT4 (Luckily I never had to use any Win9x OS on my own workstation.) and the start menu it got a bit better but it was still very slow to start applications, so I kept using the command line.


Besides being an excellent replacement for the built-in cmd.exe with many advanced and improved features, 4NT supports aliases (just like Microsoft's Powershell does now) you can define simple shortcuts to more complicated commands, in most cases I use this to start an applications.


Simple examples:

alias iis  = `start %_WINSYSDIR\inetsrv\iis.msc` (Internet Information Services console)
alias apps = `start
%_WINSYSDIR\control.exe appwiz.cpl` (Add or remove programs)
alias term = `start %_WINSYSDIR\mstsc.exe` (Terminal server client)

To make sure the aliases work on any machine, I sometimes use variable for locations
set tnOfficeDir=%@SEARCH[winword.exe]
iff %@LEN[%tnOfficeDir] != 0 THEN
    set tnOfficeDir=%@SFN[%@REPLACE[\winword.exe,,%@LOWER[%tnOfficeDir]]]
    alias word = `start %tnofficedir\winword.exe /n`
    alias excel = `start %tnofficedir\excel.exe`
    alias access = `start %tnofficedir\msaccess.exe`
endiff

I first find the Office directory and then use the variable for the that directory in my aliases, this works for all Office versions, but you may need a different approach if you have several different versions of Office installed.

In other cases I use a variable for the drive letter of my USB drive

set tnUsbDrive=%@LEFT[1,%comspec]
alias ff = `start %tnUsbDrive:\apps\PortableFirefox\PortableFirefox.exe`

I have various variables for often used directories and even application like a text editor

alias sucmd = `runas /user:%tnAdminUser %tnBinDir\4nt.exe`
alias hosts = `start %tnTextEditor %_WINSYSDIR\drivers\etc\hosts`
alias pdf = %tnToolsDir\FoxitReader.exe

The possibilities are endless.

You define your aliases in a file called 4start.cmd in the same folder as 4nt.exe, I added several other startup files which I call from 4start.cmd, here' my flow.

4start.cmd

The idea here is that I have common commands that work for every user on every machine.

4start.cmd (the main startup file), 4app.cmd (for third party apps that may be installed), 4windows.cmd (for Windows interal apps that are always there) and 4tools.cmd (for third party tools that likely to be present). Then I have three specific files 4user.cmd (for specific user settings), 4machine.cmd (for machine specific settings) and 4stick.cmd (for settings specific to the USB drive 4NT runs from). Each file can set variables or can override variables set by previous files. The two phases allow me to be very flexible with these overrides. Finally I also run a 4project.cmd which changes frequently and has locations of project folders, compiler calls or aliases to load the specific solution into Visual Studio.

During presentations, you sometimes have to start programs from the command line, mostly with many parameters, I've seen many people struggling getting it all right. You could use a batch file to prepare these commands but then the command is not visible to the audience, instead use 4NT, assign the command to an alias, then during the presentation type the alias and the Ctrl+F, which expands the alias command so the audience can see it and then hit Return to execute it.

I normally have to 4NT windows open, one runs under my normal user context and another one as a local administrator, if I need to do some work on the system or install software I can use the second command line.

Sorry, my start up files are no longer available.

Pages in this section

Categories

ASP.Net | Community | Development | IIS | IT Pro | Security | SQL (Server) | Tools | Web | Work on the road | Windows