I made a script to launch mysql from a batch file, but once the option to start the server is picked, the batch file is prevented from continuing due to executing the file.
How do I make it continue once the command is executed?
The section of code
:START
cd "C:\Program Files\MySQL\MySQL Server 5.6\bin"
CALL "mysqld" -u y121 -P 3307 &
cls
PAUSE
Related
I have a below batch script:
#echo off
cd C:\Program Files (x86)\Project
CALL init_env.bat
cd C:\Users\Documents\Project\Release
START app.exe -ver 133
echo application has been stopped
This starts the app.exe. On the terminal it also says application has been stopped. Is there any way I can pause the script after executing the line START app.exe -ver 133 and only run echo application has been stopped when the app was closed or crashed for some reason.
Thanks
The command START should be removed because it starts the executable app.exe as separate process being executed parallel to cmd.exe processing the batch file. Then cmd.exe processing the batch file starts app.exe and waits with further processing of the batch file until app.exe terminated itself.
It is also recommended to always enclose a file/folder string in " even on not really being necessary. So cd /D "C:\Program Files (x86)\Project" and call "init_env.bat" should beĀ used or even better call "C:\Program Files (x86)\Project\init_env.bat" if that works also because of batch file init_env.bat is written to work independent on what is the current directory on execution. And last cd /D "C:\Users\Documents\Project\Release" and "app.exe" -ver 133 should be written in the batch file.
Run in a command prompt window cd /? for help on command CD and meaning of option /D.
start /? outputs the help for command START in cmd window.
#echo off
call "C:\Program Files (x86)\Project\init_env.bat"
cd /D "C:\Users\Documents\Project\Release"
"app.exe" -ver 133
echo application has been stopped
See also the predefined Windows environment variables.
Currently I have a batch file running:
cd "C:\Users\chriscrutt\Desktop\"
:loop
Start /w yeet.bat
goto loop
This runs "yeet.bat". Sometimes the command prompt will crash but I need it to automatically restart. That is why I used "/w" but it requires me to manually input "N" when it asks: Terminate batch job (Y/N)? Is there a way to make it so it automatically restarts or so it will automatically say "N" to restart it?
This is how it goes. I run the bat file which runs the yeet file which runs the other program. the code for "yeet.bat" is
title ETHBTC
cd "C:\Users\chriscrutt\Google Drive\gekkoETHBTC"
node gekko
When i do "node gekko" it runs the bot.
This code do what you want: each time that yeet.bat ends for any reason it is restarted again "immediately and automatically".
cd "C:\Users\chriscrutt\Desktop\"
:loop
Start yeet.bat | set /P "="
goto loop
I am trying to make a batch file that will check certain SVN repositories for updates each morning. I want to store local repository names in a file (SVN_check_list.txt) and have the console show me the list. My code, posted below, works when I just run the batch file:
#echo off
echo Checking for updates...& echo.
for /F %%A in (SVN_check_list.txt) do (
echo Checking '%%A'
svn status %%A -u )
pause
However, when I try to run it through Windows Task Scheduler (while I am logged in), it runs the code but does not display anything until the 'pause' at the end. When I turn echo on, it shows the commands (svn status -u) but not the output. How can I make this batch file display the outputs of the svn status command even when I run it with task scheduler?
Try passing cmd as the Program/Script to run in Scheduler with arguments /k "C:\My Batch File Folder\MyScript.bat"
This will launch the console.
I found this solution that seems to work: Run a batch file with Windows task scheduler
Basically:
Action: Start a program
Program/script: cmd
Add arguments: /k "C:\Users\tanderson\Documents\setup.bat"
Start in: C:\Users\tanderson\Documents (No quotes)
I just start to learn how to build batch file. ( on the windows 7 environment)
I want to build the batch file which is able to run .exe files sequentially .
Run batch files sequentially
I was trying to apply above idea but I am not really sure how to apply it
For example, there are three file on the D:/
In "D:/" there are three .exe files.
MyDriver.exe
YouDriver.exe
Mysoftware.exe
And I would like to build batch file which is running three exe files sequentially
Possible scenario is..
Run batch file
Run MyDriver.exe
MyDriver file's install GUI pops up and then user start to install Mydriver
Done with MyDriver.exe
Run YouDriver.exe
YouDirver file's install GUI pops up and then user start to install YouDriver
Done with YouDriver.exe
Run MySoftware.exe
MySofrware install interface pops up and then user start to install MySoftware
Done exit batch file.
I am not really sure if batch files can do it or not...
if it is impossible , is there any other options to build it ???
thanks
You actually don't need to do anything special to make this happen; batch files are synchronous by default, so execution of the batch file will pause when an executable is launched, and resume when it exits. Something as simple as this should do:
#echo off
REM "#echo off" prevents each line from being printed before execution,
REM and is optional
REM "REM" introduces a comment line
D:\MyDriver.exe
D:\YouDriver.exe
D:\MySoftware.exe
Of course, if you're interested in checking the return values of the programs, to see whether they succeeded or failed to install (assuming the installer provides that information), then things become slightly more complicated; if that's what you need, mention it in a comment, and I'll expand my answer accordingly.
This will start each file and wait for it to complete and then launch the next one.
#echo off
start "" /w /b "d:\MyDriver.exe"
start "" /w /b "d:\YouDriver.exe"
start "" /w /b "d:\Mysoftware.exe"
start MyDriver.exe
start YouDriver.exe
start MySoftware.exe
If you want the batch file in a different dir you would have to do:
cd D:\
start MyDriver.exe
start YouDriver.exe
start MySoftware.exe
If you want a more flexible system:
echo Welcome to EXE starter!
set /p dir = DIR:
set /p exe = EXE1:
set /p exe1 = EXE2:
set /p exe 2 = EXE3:
cd DIR
start exe
start exe1
start exe2
There you go!
To do it squentially:
call YouDriver.exe
call MeDriver.exe
call Mysoftware.exe
call will halt the batch file until program has closed.
Try and put it in the same directory of the files you want to run. If you can't, use cd C:\Directory\Name to change it to the directory where the MyDriver.exe file is. Then just do MyDriver.exe- you don't need a call or start statement.
MyDriver.exe
YouDriver.exe
MySoftware.exe
use cd at the start if you neeed to.
I have an issue with my batch script that's configured to run every 6 hours every day through Windows Task Scheduler. The batch does it's job if I run the Schedule or batch manually, but not when it's run automatically.
Here's how the batch looks like:
#echo off
cd "C:\Program Files (x86)\Steam\SteamApps\common\Arma 2 CO\instance_11_Chernarus"
cscript /nologo "C:\Users\Administrator\Desktop\Batch Jobs\DayZ Epoch\timezone.vbs" > newfile 2>> error.log
del config.cfg
ren newfile config.cfg
ping 127.0.0.1 -n 3 >NUL
cd "C:\Program Files (x86)\Steam\SteamApps\common\Arma 2 CO"
start "arma2" /min "C:\Program Files (x86)\Steam\SteamApps\common\Arma 2 CO\Expansion\beta\arma2oaserver.exe" -port=2302 "-config=instance_11_Chernarus\config.cfg" "-cfg=instance_11_Chernarus\basic.cfg" "-profiles=instance_11_Chernarus" -name=instance_11_Chernarus "-mod=#DayZ_Epoch;#DayZ_Epoch_Server;"
cd C:\Users\Administrator\Desktop\BEC\
start C:\Users\Administrator\Desktop\BEC\bec.exe -f Config.cfg
Now, the batchs' job is to restart a Arma 2 OA Game server, and when I run the script manually, the server restarts well, although, when it's being run automatically, the server throws me an error with "No entry Cfg.worlds" and that's an error that something on this line has not been included in the server properly:
start "arma2" /min "C:\Program Files (x86)\Steam\SteamApps\common\Arma 2 CO\Expansion\beta\arma2oaserver.exe" -port=2302 "-config=instance_11_Chernarus\config.cfg" "-cfg=instance_11_Chernarus\basic.cfg" "-profiles=instance_11_Chernarus" -name=instance_11_Chernarus "-mod=#DayZ_Epoch;#DayZ_Epoch_Server;"
The system account which task scheduler uses by default has no access to network resources - so if your server is on a network and you are not using credentials with enough access then that will be the reason.