I am trying to create a .Bat file that only runs and copy's things if the file Startapp.bat exits. This startapp file is created when a user commits code on github.
I have the following script.
taskkill /F /IM Webshop.exe
::%~dp0 means the current folder where this .bat is executed from
SET dest=%~dp0productionEnv
IF EXIST "%~dp0startApp.bat" (
if not exist "%dest%" mkdir "%dest%"
xcopy /Y /s "%~dp0Webshop\bin\Debug" "%dest%"
SET webDest="%dest%/webContent"
if not exist %webDest% mkdir %webDest%
xcopy /Y /s "%~dp0Webshop\webContent\web" %webDest%
copy /Y "%~dp0startApp.bat" "%dest%/startApp.bat"
START "" "%dest%/startApp.bat"
del "%~dp0startApp.bat"
echo "Deleted startApp.bat"
) ELSE (
echo "startApp.bat file not found"
)
But it is not working. Sometimes it echos both the deleted message and the file not found message while that shouldn't be possible. It should echo either of those messages but not both. Thats why there is an if else.
Please help!