Specifically, I'm using DGIndex in a batch file as part of a sequence to do some video encoding.
Despite accepting CLI params, DGIndex pops up a window to do the processing. This then disappears when it's finished, but the command line hangs as though it's still open. The process is no longer running.
Is there something built-in that I can do to ensure it doesn't hang, or is there a third-party proxy utility that will monitor for a process end then close itself?
I had the same problem with DGIndex in batch files. I know this is an old question, but it seems DGIndex hasn't been updated since then, so this might still be relevant.
DGIndex has 2 different command-line "styles", in the manual one being called legacy (the one using upper case letters for the settings), the other UNIX-style (lower case letters).
For me, the "-exit" command of the UNIX-style command-line did not work, so that the batch file did not receive a corresponding message from DGIndex, even though it finished its job correctly. I used the legacy commands instead, and the problem was gone.
"Funny" that Dan had the problem with the legacy commands, so the other way round.
Regards, Mike.
You could use something like this:
#echo off
echo Running program
start dgindex -BF=[vob.txt] -FO=0 -IA=2 -OM=2 -TN=0 -OF=[out] -HIDE -EXIT
ping 127.0.0.1 -n 10
taskkill /im dgindex.exe /f
exit >nul
This batch file basically runs the DGIndex program and then pauses for 10 seconds before attempting to close the program. Just replace the 10 with a delay of your choice, something long enough that if the program is still running it means it's crashed, then it will be closed after the delay.
I'm pretty sure you can't tell if the program has hung or not (at least not in batch anyways). This at least makes sure it isn't running if you need to run it again if it did crash.
Hope this helps!
If you use start, the batch file should return immediately after starting the dgindex application.
You can pass the /WAIT flag to start to it to tell it to wait until the process has exited before moving to the next line of the batch file.
start /WAIT dgindex -BF=[vob.txt] -FO=0 -IA=2 -OM=2 -TN=0 -OF=[out] -HIDE -EXIT
I know this is old, but did you ever get it figured out?
Related
I have 2 batch files (1.bat and 2.bat). I want 2.bat to run when 1.bat closes. Is that possible?
Or is there a way to close a batch file when a batch file closes. Here is my code which doesnt work:
cd C:\xampp
start apache_start.bat
cd C:\Users\MinecraftServer\Desktop\1.12.2MinecraftServer
MC1.12.2Start.bat
taskkill /F /IM cmd.exe /T
I have a minecraft server running with a .bat file and a web server running off of a .bat file (using xampp, its used for prtg monitorng).
start will create a completely independent process and continue immediately to your next batch command. That independent process may do a job and terminate, or may say open an application like notepad and wait until the notepad is closed. Regardless, a straight start command will not stop the batch that it is in - the next step will be executed, whether or not the process that has been started has terminated.
You can also add the /wait switch to start. If this switch is used, the batch will wait until the started process terminates.
Preferred syntax for start is
start /wait "window title" executable parameters...
where "window title" may be an empty, but not absent string. Including this as the first parameter is preferred because the first quoted string in a start command is used as a window title for the started process, and thus start may not act as expected where the executable or any of its parameters is quoted.
call executablename... will wait for that executable to terminate before progressing to the next step. This may or may not be what is desired.
MC1.12.2Start.bat in your code will SWITCH to that batch and remaining batch lines will be ignored.
Which may be fortunate in this case, since as you've coded it, the apache_start.bat may or may not have completed when the taskkill command is run, killing all cmd.exe sessions.
I seek a simple script/batch file to close a program at a certain time. Someone recently gave me a single line of text that I put into a notepad and had Task Manager run this file at a certain time and that worked. But I had to format that hard drive and lost the file.
So my goal is to run a batch file that will kill a process at a set time each day. Let's call the program flubber.exe. I'm not a programmer and the research I've done on tskill has only confused me. I know it was a simple short command but I am unable to remember it. Help.....
Thank you to all who respond.
Majikwiz
taskkill /im flubber.exe /t
This will terminate all running processes with executable name flubber.exe.
I'm pretty much a noob at this, so any help is appreciated.
I'm trying to run the video transcoding executable REDline on all .R3D files in a given folder. REDline only accepts single files, which is the issue. I finally got it to search recursively for the files I need, but my problem is the search function passes the next result to REDline before the first one is finished transcoding. I have the search results that need to run in a variable inside REDline.
Here's the code:
for /r D:\folder\ %%a in (*) do (
"C:/Program Files/REDCINE-X PRO 64-bit/REDLine.exe" --exportPreset "Prores_Intermediate" --i "%%~dpnxa" --useRSX 2 --masterRMDFolder "" -s 0 -e 95
)
After about .7 seconds, REDline reports 'received stop message from client'.
I don't think this is a REDline error, as I have been able to transcode single files successfully.
Thanks.
Try start /wait when running the executable.
If that does not help, the executable might start another executable which does the actual job. In that case identify the other executable using Process Monitor or Process Explorer. Check their command line parameter to see if you can run that executable directly.
If you can't run the other process yourself, you can wait until that process has exited. See Wait for executable to finish here on StackOverflow.
Im not familiar with that particular executable, but here are some suggestions you may try:
- Check the allowed parameters for REDLine.exe (documentation or possibly /?) to find out if there is any that might address your problem
- There are tools that allow you to check for the existance of a process (Microsoft Sysinternals, check the ones starting with PS*.exe) http://technet.microsoft.com/de-de/sysinternals/bb545021.aspx
Use this to improve your loop so that you check if the process is running first before continuing with the next loop - or loop without doing anything until the process has exited, you can do with repeatedly calling a ping to localhost inside your loop for a fixed time interval for example
- Check the errorcodes returned by programs to see if that helps you
- Put the code that starts your encoding inside its own batch file, and the check if the process is currently running as well
- Use the creation of a dummy file before starting and delete it once finished to discern if an instance of your batch is running
- Check the difference between calling a command directly from a batch file, and using the start command to run it at the same time
This question already has answers here:
Force a "real" BSoD on windows 10, or corrupt its OS
(7 answers)
Closed 1 year ago.
Is there a way is batch or vbs to force the blue screen of death to appear, or a forced crash. This can happen from stopping the process "csrss.exe" but it wont close via simple batch or vbs script. How can this be done?
Try NotMyFault by Sysinternals.
If you run a .bat file with %0|%0 inside, your computer starts to use a lot of memory and after several minutes, is restarted.
%0 is the name of the currently executing batch file. A batch file that simply does:
%0|%0
Is going to recursively execute itself forever, quickly creating many processes and slowing the system down.
It's a logic bomb, it keeps recreating itself and takes up all your CPU resources. It overloads your computer with too many processes and it forces it to shut down. If you make a batch file with this in it and start it you can end it using taskmgr. You have to do this pretty quickly or your computer will be to slow to do anything.
This is known as a fork bomb.
It keeps splitting itself until there is no option but to restart the system.
http://en.wikipedia.org/wiki/Fork_bomb
This is not a bug in windows, it is just a very stupid thing to do in a batch file. so if you want to test it, you must save your work before.
Not sure why you would want this, but...
#echo off
taskkill /f /im wininit.exe
pause
You might need to set this to run as an Administrator.
set ramconsumer = createobject("wscript.shell")
do
ramconsumer.run wscript.scriptname
loop
not shure why you need it but here it is a vbs version
I am using the tool 'HTML Match' to compare two HTML files. As I have to compare many files, I create a batch file like the followion. For example, I give only five sets of files.
cd "C:\Program Files\HTML Match"
HTMLMATCH.EXE "D:\Raj\compare1\a1.html" "D:\Raj\compare2\a1.html" "D:\Raj\compare_res\a1.html"
HTMLMATCH.EXE "D:\Raj\compare1\a2.html" "D:\Raj\compare2\a2.html" "D:\Raj\compare_res\a2.html"
HTMLMATCH.EXE "D:\Raj\compare1\a3.html" "D:\Raj\compare2\a3.html" "D:\Raj\compare_res\a3.html"
HTMLMATCH.EXE "D:\Raj\compare1\a4.html" "D:\Raj\compare2\a4.html" "D:\Raj\compare_res\a4.html"
HTMLMATCH.EXE "D:\Raj\compare1\a5.html" "D:\Raj\compare2\a5.html" "D:\Raj\compare_res\a5.html"
When I execute this batch file in a cmd prompt, only the first line, that is, only 'a1.html', gets compared and produces a result. Then execution stops.
Add call in front of the commands you're running.
You can also change this to a for loop, so:
FOR /L %%i in (1,1,5) DO CALL HTMLMATCH.EXE D:\Raj\compare%%i%%\a%%i%%.html D:\Raj\compare%%i%%\a%%i%%.html D:\Raj\compare_res\a%%i%%.html
The answer to your problem is to write CALL HTMLMATCH.EXE (and the rest of the parameters).
Just use CALL in front of every executable command in the batch file.
I was looking for something really similar and tried, I think, all the replies left here but I finally found the solution to my problem!!
In my script I want to check if one process is running, if not, start it (a .exe) and then check if another process is running, if not, start it too (but leave all the programs opened) and the problem is that the first .exe was started but then not moving to the second one because it was waiting until the process ended.
It´s finally working for me with start and the magic comes with...
/separate
it works for me as:
start "program1" /separate program1.exe
other commands
Before it stopped after starting program1 because it was waiting until it was closed, I think, but this was not going to happen because I wanted to leave it opened.
Now with the start /separate it continues with the other commands.
I found it in another forum but the thing is that it´s the manual, /separate is used to start in another memory space.
You don't have to insert quotation marks where there isn't any space mark between.
Try that:
HTMLMATCH.EXE D:\Raj\compare1\a1.html D:\Raj\compare2\a1.html D:\Raj\compare_res\a1.html
Maybe it will solve your issue.