
- #CMD C EXIT PORTABLE#
- #CMD C EXIT CODE#
This also means we can't call this version with any other parameters than max. Testing ErrorLevel works for console applications, but as hinted at by dmihailescu, this wont work if youre trying to run a windowed application (e.g. This means we executed the start /max your batchfile and in the meantime exit the current batch. To be more explicit about what others have said: Don't think too hard about it.
#CMD C EXIT PORTABLE#
It's not portable, though, the only portable exit values are 0, EXITSUCCESS and EXITFAILURE.
#CMD C EXIT CODE#
& exit/b: The & means execute the next command simultaneous with the previous. 42 is clearly the opposite of a named value - it's a magic value that only the author of the code knows why it's there. This means we need to skip that first if-line or else we get caught in a loop :) The %0 stands for your own batch-file name and here max is its first parameter. cmd /c execute cmd.exe and /c means exit afterwards. start /MAX start the command after it, in maximized form. If we didn't start the batch with a max parameter we need to execute this line. So my_batch.bat max will have max in the %1-variable. %1 stands for the first parameter given to the batch-file. 2) Alternately you may use want to run the cmd in hidden mode (not minimized). This will execute the scripts and in the end, the cmd will exit. save it as something.bat and run it whenever needed. if not "%1" = "max" execute the next command only if %1 is not "max". 1) Use a batch script and in the last line, simply add exit to the script. If the batch is not called with the parameter max we call itself again ( %0), this time maximized with the help of start /max, and with the parameter max and that way the second time its called it will skip the if-statement and continue with your commands. There will be a slight flicker of the original batch-file (which will exit immediately) before starting the maximized version. :: here comes the rest of your batch-file If not "%1" = "max" start /MAX cmd /c %0 max & exit/b I've created a small example which shows how you could do it all in one batch-file cmd.exe /c start /min myfile.bat & exit the cmd.exe is needed as start is no windows command that can be executed outside a batch /c exit after the start is finished the & exit part ensures that the window closes even if the batch does not end with exit However, the initial cmd is still not minimized.
START - Run a program, command or batch file. CALL - Call one batch program from another. EXIT - Use this to close a CMD shell and return. CMD Shell - Tips on working in the Windows CMD shell. You can try start /MAX yourscript.bat to start your script in a maximized cmd (up to Windows 7) CMD /c ''c:\Program Files\demo1.cmd' & 'c:\Program Files\demo2.cmd'' Those who can command themselves, command others Hazlitt.