I'm using TinyWeb server. I run it using a batch file START_tiny.bat:
c:
cd\
cd tiny
cd bin
tiny c:\tiny\root 8080
exit
The problem is that after tiny.exe is executed, the console won't close so it hangs here:
I can manually close the console window, and it will continue to run as expected, but I was just wondering if there was a way in the batch file to make sure it closes after the program is invoked.
EDIT: the solution was:
cmd /c start tiny c:\tiny\root 8080
The Windows Command Processor cmd.exe
halts processing of the batch file as long as tiny.exe
is running and waits for its termination, even if this application is a GUI application not opening any window or opening a GUI window.
The command exit
is not necessary at all and is just bad for debugging the batch file.
It would be better to use a shortcut file (*.lnk) to just start TinyWeb server. Target in properties of shortcut file would be C:\tiny\bin\tiny.exe C:\tiny\root 8080
and Start in would be C:\tiny\bin
or C:\tiny\root
or whatever should be the current directory on starting TinyWeb. No console window is shown on tiny.exe
not being a console application which I don't know as not having downloaded and installed this application.
The command start
can be used in a batch file for starting TinyWeb server as separate process by cmd.exe
without waiting for its termination.
One of the following command lines could be used in the batch file:
start C:\tiny\bin\tiny.exe C:\tiny\root 8080
start /DC:\tiny\bin tiny.exe C:\tiny\root 8080
start /D C:\tiny\bin tiny.exe C:\tiny\root 8080
start "TinyWeb server" C:\tiny\bin\tiny.exe C:\tiny\root 8080
start "TinyWeb server" "C:\tiny\bin\tiny.exe" "C:\tiny\root" 8080
start "TinyWeb server" /D"C:\tiny\bin" tiny.exe "C:\tiny\root" 8080
start "TinyWeb server" /D "C:\tiny\bin" tiny.exe "C:\tiny\root" 8080
Open a command prompt, run start /?
and read the output help for an explanation of the above command lines.
The parameter /D
specifies the start in respectively current directory for the started executable. It can be specified immediately after /D
or separated with a space from the switch.
Command start
interprets first string in quotes as window title. For that reason it is necessary to explicitly specify a window title in double quotes on one of the other arguments is enclosed in double quotes even if no console window is opened because of started application is a Windows GUI application. An empty title string specified with just ""
is enough for GUI applications started by command start
as separate process.
The command line cd /D "C:\tiny\bin"
can be used to change current directory to C:\tiny\bin
even on current directory being on a different drive. The help output on running in a cmd window cd /?
explains the parameter /D
to change also drive if necessary and not only current directory on current drive.