0

i'm trying to make a loading bar batch file that opens a .exe (HDDLED.exe) file, but it will stay open until i close the .exe file, i have searched the internet but what i could find is this: start"" " , exit , tskill cmd.exe , and some other stuff, but it will not work, here's the code:

@echo off
color 0a
echo.
echo ---------------------------------------
echo                                 =   0 ]
echo ---------------------------------------
ping localhost -n 1 >nul
cls
echo.
echo ---------------------------------------
echo []                              =   5 ]
echo ---------------------------------------
ping localhost -n 1 >nul
cls
echo.
echo ---------------------------------------
echo [][]                            =  15 ]
echo ---------------------------------------
ping localhost -n 1 >nul
cls
echo.
echo ---------------------------------------
echo [][][]                          =  23 ]
echo ---------------------------------------
ping localhost -n 1 >nul
cls
echo.
echo ---------------------------------------
echo [][][][]                        =  30 ]
echo ---------------------------------------
ping localhost -n 1 >nul
cls
echo.
echo ---------------------------------------
echo [][][][][]                      =  38 ]
echo ---------------------------------------
ping localhost -n 1 >nul
cls
echo.
echo ---------------------------------------
echo [][][][][]                      =  42 ]
echo ---------------------------------------
ping localhost -n 1 >nul
cls
echo.
echo ---------------------------------------
echo [][][][][][]                    =  45 ]
echo ---------------------------------------
ping localhost -n 1 >nul
cls
echo.
echo ---------------------------------------
echo [][][][][][][]                  =  48 ]
echo ---------------------------------------
ping localhost -n 1 >nul
cls
echo.
echo ---------------------------------------
echo [][][][][][][][]                =  50 ]
echo ---------------------------------------
ping localhost -n 1 >nul
cls
echo.
echo ---------------------------------------
echo [][][][][][][][][]              =  56 ]
echo ---------------------------------------
ping localhost -n 1 >nul
cls
echo.
echo ---------------------------------------
echo [][][][][][][][][][]            =  63 ]
echo ---------------------------------------
ping localhost -n 1 >nul
cls
echo.
echo ---------------------------------------
echo [][][][][][][][][][][]          =  69 ]
echo ---------------------------------------
ping localhost -n 1 >nul
cls
echo.
echo ---------------------------------------
echo [][][][][][][][][][][][]        =  75 ]
echo ---------------------------------------
ping localhost -n 1 >nul
cls
echo.
echo ---------------------------------------
echo [][][][][][][][][][][][][]      =  79 ]
echo ---------------------------------------
ping localhost -n 1 >nul
cls
echo.
echo ---------------------------------------
echo [][][][][][][][][][][][][][]    =  86 ]
echo ---------------------------------------
ping localhost -n 1 >nul
cls
echo.
echo ---------------------------------------
echo [][][][][][][][][][][][][][][]  =  90 ]
echo ---------------------------------------
ping localhost -n 1 >nul
cls
echo.
echo ---------------------------------------
echo [][][][][][][][][][][][][][][]  =  96 ]
echo ---------------------------------------
ping localhost -n 1 >nul
cls
echo.
echo         Welcome to HDDLED...
echo ---------------------------------------
echo [][][][][][][][][][][][][][][][]= 100 ]
echo ---------------------------------------


ping localhost -n 2 >nul
pause

pushd %~dp0
HDDLED.exe
popd"

*insert exit code here*

here's where i got the code,

And here's where i got the HDDLED.exe file.

ps, sorry for my bad english, i'm not a native speaker

  • 3
    Possible duplicate of [Windows batch script launch program and exit console](https://stackoverflow.com/questions/5909012/windows-batch-script-launch-program-and-exit-console) – bgfvdu3w Sep 28 '17 at 02:57
  • Have you perhaps tried `exit`? – Gerhard Sep 28 '17 at 05:52

1 Answers1

1

Replace the command block

pushd %~dp0
HDDLED.exe
popd"

with the completely wrong " in last line by

start "HDDLED" /D"%~dp0" HDDLED.exe

The command START starts a new process with setting the directory of the batch file as current directory before starting HDDLED.exe. This new process running parallel to command process processing the batch file is also a command process if HDDLED.exe is a console application and not a Windows GUI application. In this case the new command process opens also a console window with title HDDLED as specified as first parameter in double quotes.

Run in a command prompt window start /? to get output the help explaining this command and its options.

After START was executed the Windows command interpreter cmd.exe immediately continues processing the batch file. The batch file processing exits with no more lines in batch file. This means the command process exits if the batch file was double clicked for execution.

I suggest further to replace ping by %SystemRoot%\System32\ping.exe to make your batch file independent on the values of the environment variables PATHEXT and PATH.

I suppose localhost is not really specified in your batch file as in this case -n 1 would not make sense at all because the echo request is always immediately answered by local host computer.

An advice: You should replace the entire batch code above output of Welcome to HDDLED... by a command block using either a FOR loop with for /L %%I in (1,1,100) do (...) or a label with GOTO command and set /A Number+=1. Run in a command prompt window for /? and goto /? and set /? for help on those 3 commands. A FOR loop can be broken at any time by jumping with command GOTO to a label below the FOR loop.

Mofi
  • 46,139
  • 17
  • 80
  • 143