I want to create a batch file to start MySQL server (mysqld) and Rails Thin server (rails s thin). But only MySQL starts, rails s thin doesn't:
#ECHO OFF
cd C:\path\to\app
CMD /C "mysqld --console"
REM exit <-- with or without it
REM cd C:\path\to\app <-- with or without it
CMD /C "rails s thin"
I also tried to create three files for this. The main one runs other two. Doesn't help either, only MySQL runs. And I need to start MySQL before Rails. Rails needs running MySQL. How to write such a batch?
UPD:
How to start 2 programs simultaniously in windows command prompt
use start
e.g.
start notepad.exe
start calc.exe
if you want to run one after another with some tests, you may need to write your own program.
Related
I'm trying to run a batch file from a local Windows server that calls on computers in my domain to pull from the shared folder and run an exe. I'm not sure if my script is trying to do too much or too little.
So I run the below batch locally
X:\pstools\psexec.exe \\Computer -d -u DOMAIN\user -p password -i \\SERVER\test\testfile.bat
and testfile.bat:
#echo off
pushd \\SERVER\test\
call program.exe
popd
When I run the script, psexec runs and I get a confirmation that testfile.bat was started on target computer. On the targeted computer nothing happens. If I navigate to the share on the targeted computer and run testfile.bat, I get "CMD.EXE was not started with the above path as the current directory.UNC paths are not supported. Defaulting to Windows directory." From there the computer runs the called .exe with no issues.
If I target this towards another server in my domain it executes perfectly, but not on domain computers. I thought maybe a GPO issue, but I can't find a solution.
Thanks for any knowledge or help provided!
Thanks for all the tips everyone! This is how I ended up getting it working for anyone who might have the same issue.
Script on Server:
x:\pstools\psexec.exe \\Computer(or text file with computers listed) -d -s cmd /c (batchfile.bat)
Similiar to what I was trying before, but to ensure you run the command line as System on the remote PC you have to specify "-s cmd". The /c copies the batch to the remote system to run locally. You can include a "-f" to overwrite if you've already copied it previously. I just put the batchfile in the pstools folder.
Batchfile.bat:
pushd \\networkdrive
call (.bat/.cmd/.exe/etc.)
popd
I disabled the firewall for testing, but I believe you have to open TCP-445/UDP-137 for PSEXEC. Otherwise, that's it. Super simple solution.
The issue
I am trying to create a batch file that will execute the following two commands:
cd /some/path
dotnet run
that produces the following output:
It starts my localhost server.
Trying To Accomplish
What I would like to do is, put those two commands in a batch file and automatically open Chrome to the server address, HOWEVER, the dotnet command takes some time to finish. So somehow, I would have to keep monitoring localhost to see if it is available.
Any help would be appreciated. Although opening a CMD window, typing those 2 commands, and waiting a minute isn't all that much of a problem, it sure would be nice to just click on a batch file.
Thank you.
You can create a batch file like this code :
#echo off
Set "ApplicationPath=%UserProfile%\source\repos\PruttPos\PruttPosSystem\"
CD /D "%ApplicationPath%"
dotnet run
Start "Chrome" Chrome.exe "http://localhost:5000"
pause
START "Test Server" "%~dp0\server.exe" LAN %M%.aao log=server.log ini=server.ini
Everything after "LAN" is not being executed by server.exe I can see in the servers log file that it is trying to open lan but it should be trying to open %m%.aao which means everything after "LAN" is being ignored.
How can I fix this?
Using
START "Test Server" server.exe LAN %M%.aao log=server.log ini=server.ini
will not work as I'm trying to run the batch file from WOTGreal. I am unsure why, but the way I fixed it for the other two files/programs I open was to use %~dp0, but the server requires that the spaces not be ignored.
I'm trying to run the batch file from WOTGreal
So the batchfile will be run from a different folder. That will also mean server.exe will be run from a different folder. so local filenames like in %M%.aao log=server.log ini=server.ini will be read from the wrong directory.
You could probably fix that by also using %~dp0 in all other paths. But it is probably easier to change the current directory at the start of the batchfile. To do that, add the following line to the start of the batchfile.
cd /d "%~dp0"
We have a configured TFS CI which is making our build. After a build I`d like to have my simple executable application to be deployed to specific folder on the server and then started.
I decided to do this with post-build step and batch script. Everything works perfectly except one:
when the application is stared, build agent(the one who runs my script) hangs.
Here is how I start my application from the script:
start /b %depldir%\MyApp.exe [params] > log.txt
So I start it in backgroound and redirect std out/error to file.
Application is started correctly but build process won`t finish untill I kill the application.
How do I start my application without build agent waiting for it to finish?
I'm not sure if this is a bug but if you use start /b something > logfile.txt the new and hidden cmd window is started with parameter /k. This forces the hidden window to stay active. This makes the calling bat wait for it to exit and this is why your build won't terminate. To verify this I've created two files:
starter.bat:
start /b tostart.bat > log.txt
tostart.bat:
echo started
When I start starter.bat the cmd doesn't terminate and in the task manager the following process appears:
cmd.exe USER 00 00:00:00 1.400k C:\Windows\system32\cmd.exe /K
tostart.bat
/K means:
/K Run Command and then return to the CMD prompt.
This is useful for testing, to examine variables (taken from http://ss64.com/nt/cmd.html)
To cut a long story short: it works fine when you replace start /b with call. Unfortunately call doesn't have a parameter like /b so your application won't start in background. I don't know whether this is a problem for you.
If it is: I've faced similar problems with my Jenkins build server. My solution was to create a task which runs my application (in background). Instead of calling the program itself I just call SCHTASKS /Run /TN "TASK_NAME". This command just triggers the task without waiting. This way you can also avoid problems with permissions etc.
I have created a python script that I would like to run every time I start my computer.
So I started creating a batch file that could later be put into my startup folder.
I tried this:
#echo off
start "C:\Users..........." (I gave the exact path)
and when I run it you can see the python script pop up for a moment, but then shuts down. What am I doing wrong?
this works here:
#echo off
start /b "" "%ProgramFiles%\Python33\python.exe" "%UserProfile%\Test.py" "more parameters"
pause