Page 1 of 1

[Undocumented] START

Posted: 30 Nov 2013 00:07
by carlos
START without command to execute:
START ""
START


first it look for a program called CMD.EXE in the current directory and launch it.
if it not exist it launch windows\system32\cmd.exe
even if COMSPEC value is different than windows\system32\cmd.exe or is not defined.

START batch_script or internal_command:
START "" dir
START "" file.cmd


In both cases COMSPEC variable will be considered.

if COMSPEC variable is not defined then message like this is printed:
The environment variable COMSPEC not points CMD.EXE.
and return a errorlevel 0.

Else If COMSPEC points to an application then it launch this:
%COMSPEC%
/K
command
more arguments


For example if you defined COMSPEC like this:

Code: Select all

set COMSPEC=%Windir%\system32\Calc.exe


and you do:

Code: Select all

START "" dir /?

it will execute:

Code: Select all

%Windir%\system32\Calc.exe /K dir /?


Else If COMSPEC points to a batch script then it launch:
cmd /c %COMSPEC% /K batch_script

Note: In this case, with extensions and without extensions "cmd " points to windows\system32\cmd.exe avoiding a cmd.exe in the current folder. This last is similar to something that says the documentation, but this is differente because "cmd " is not replace by the COMSPEC variable (that is a batch script name) and works with extensions disabled.

for example if:

Code: Select all

set COMSPEC=Launch.cmd

and we run:

Code: Select all

START execute.bat

it will run:

Code: Select all

cmd /c Launch.cmd /K execute.bat


If COMSPEC is defined and the file that points not exists:
a message like this is printed:
the system cannot found the file ...
and return errorlevel 9059.