Version 19 of start

Updated 2006-09-14 08:09:50

[Refer to Microsoft documentation.]

MS-DOS shell built-in command called with a filename that invokes the executable associated with the filename's extension. Acts about like double-clicking on a file in File explorer. Usage example from Tcl:

 eval exec [auto_execok start] "" [list [file nativename $filename]]

How does 8.5 spell that? Is it

  exec {expand}[auto_execok start] "" [file nativename $filename]

?

which, if filename ends e.g. in .htm, calls up IE (if that's your default browser); Win Word for .doc, etc.

Nits: If the first parameter is quoted, "start" will take it for a window title. Add an empty string to avoid the problem (see below). COMMAND.COM, CMD.EXE and the console command-line tools misunderstand "/" in filenames. Use [file nativename] to cure that.

[Use in invoking browsers.]

To launch a Windows application (such as Tk) from a console application (such as Tcl) in such a way that it returns only after the subprocess has terminated, use

      start /w wish83 myapp.tcl

As with most Windows command-line tools, see "start /?" from a command prompt for built-in help.


schlenk One caveat usually found the hard way, is the simple fact, that Microsoft found it amusing to implement start differently on Win9x and on Win2k/XP. So read its documentation before you use it. Try to start something like this on W95 and W2k an see what happens:

 start "c:\program files\tcl\bin\wish84" myapp.tcl

Hint (this works on W2k):

 start "" "c:\program files\tcl\bin\wish84" myapp.tcl

MHo: Some (other or additional) aspects and facts of start:

  • You can start something specifying (registered) a file instead of the associated program, e.g.: start test1.tcl or start text1.doc; (hopefully) the right program is opened with the specified file as an argument automatically (have a look at the cmds ftype and assoc for file type - program associations).
  • As noted, start /W(ait) is 1) a way to serialize things and 2) the only way to get back the errorlevel from win32-GUI programs (console mode programs always start synchronously even without using start).
  • start is an internal command an on NT/W2k/XP etc., that means: it is build right in cmd.exe, the command shell interpreter. On Win 9.x it is an separate executable (start.exe).
  • And to make things not too simple, the parameters/switches accepted by start are different on 9x and nt-based platforms.


[Explain winutils alternative--something like "winutils::shell myfile.doc", and so on]


[category?]