I need to figure out this seemingly very simple issue on windows .bat file. I have been using Linux for past 10 years full-time, so I am in pretty unfamiliar territory when it comes to .bat scripts.
We have some units tests that need to run on from this .bat file, and a build needs to be generated after the tests have run.
The bat file itself is very simple, I was thinking of just chaining the commands:
cls
echo "Running test suite - CRMSync"
echo
echo
REM from command: --static-backup
phpunit --bootstrap test/bootstrap_test.php --verbose --log-junit
echo "Running phploc for CRMSync"
phploc --count-tests --verbose > C:\CRMsync\testResults\phploc\index.html
echo "Executing phing"
phing
Now, simple enough except nothing is executed past phpunit command. How do I deal with this?
The unit tests run fine, but I am suspecting it could even be in the unit test lib that process is killed. Is there a way to fork the process somehow or get the other commands below to run?
Thanks SO'ers, as always, any help greatly appreciated.
I had the same problem for a development script that I made. And I tried all given solutions without being successful. At the end, I did it with cmd /C.
From the windows docs it will:
Run Command and then terminate
So for example, you can use it as follows:
cls
echo "Running test suite - CRMSync"
echo
echo
REM from command: --static-backup
cmd /C phpunit --bootstrap test/bootstrap_test.php --verbose --log-junit
echo "Running phploc for CRMSync"
cmd /C phploc --count-tests --verbose > C:\CRMsync\testResults\phploc\index.html
echo "Executing phing"
cmd /C phing
I hope you find this useful.
Similar to the post ujifgc, I use "start /b ..." in these situations. If you encapsulate the call to phpunit in another batch file, you can use "call".
Is phpunit itself a batch file (I don't do much PHP, so am not familiar with the tool)? If so, try using:
call phpunit --bootstrap test/bootstrap_test.php --verbose --log-junit
Try start /WAIT phpunit ... to fork process and wait for it or just start phpunit ... to fork and continue. Help is here: start /?
I used
start /b code .
cmd /k ng serve --build-optimizer --aot
to start Visual Studio Code and then a node js server.
But the Command line glitched with the % update text and more.
I then used
cmd /C code .
cmd /k ng serve --build-optimizer --aot
and the glitching stopped for the server progress update.
Related
This seems like such a basic thing..kill app & restart it..
I have this batch file configure to run daily through windows task scheduler:
#ECHO OFF
::Daily reboot to limit ram usage
taskkill /F /IM javaw.exe
::
:: start app again
::
start app.jar
The script is run each day successfully according to windows but it is only closing the program not starting it again. When I double click my .bat file it works just fine..
What am I missing?
Well I'm in my first year of bachelor only using BlueJ so far to learn java so I apologize.
Happy that I now know the task run from c:\win\sys32. I could see the logs from the java app there not finding the libraries. so the #CD /D "%~dp0" I'll try to remember for sure. Thx
final code:
#CD /D "%~dp0"
::Daily reboot to limit ram usage
taskkill /F /IM javaw.exe
::
:: start app again
::
start java -jar d:\path\to\app.jar
full path to javaw.exe was not needed, only diff when running the app with task scheduler is that the last line in log should be "added to SystemTray" making the app visible. Now it is running hidden, which is ok for it's use but I'll try to figure out on my own why.
(just "start app.jar" is also working just fine btw with the #CD /D "%~dp0" on top.)
thx,
First make sure you have configured environment variable for running java.exe . If not, refer this .
Secondly, always use complete path to start/kill your jar execution.
The command to run your application is:
java -jar app.jar
I made a .bat file which is supposed to run Thunderbird minimized.
Here's what I put in it so far:
start /min "" C:\"Program Files (x86)"\"Mozilla Thunderbird"\thunderbird.exe runas /user:Administrator
I tried several tests:
- Removing /min
- Adding the runas option for administrator rights
- Adding the first empty quotes after start
- Writing the whole path into quotes
- ...etc.
Everything that happens is the .bat launches, but nothing furthermore happens.
I have no error in the CMD window.
Why isn't it working ??
My purpose is to put that .bat in startup folder so that Thunderbird launches minimized on startup.
I used to use an extension (MinimizeOnStartup) for Thunderbird, but it's no longer compatible with latest version and I couldn't manage to find any alternative.
I read through here, it wasn't enough to help:
A batch file to minimize other applications
Can you help me?
Thank you.
Using Windows 10.
Try the following (modify it accordingly)
cd C:\Program Files (x86)\Mozilla Thunderbird\
start /min thunderbird.exe runas /user:Administrator
A solution posted on reddit https://www.reddit.com/r/Thunderbird/comments/bnt6u3/ive_created_a_small_script_to_minimize/ ...
This is Windows only. You'll need NirCMD for this. NirCMD will trigger the "Minimize" Event after we've started Thunderbird. Get it here: https://www.nirsoft.net/utils/nircmd.html
The script:
START "" "C:\Program Files\Mozilla Thunderbird\thunderbird.exe"
timeout /T 3 /nobreak
"nircmd.exe" win min process "thunderbird.exe"
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
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.