Solved
thank you so much for helping me Jean-François Fabre, haveing someone who was thinking along with me kept me motivated to keep figuring things out myself!
what i ended up doing is using a timer script, that first boots up the scanning script, after 900 seconds of pauze the timer proceeds to open a vbs script that closes cmd and opens the timer again to do another 15 minute loop.
how to close a batch file with another batch file
C:\pokemongo-api-demo-maps>taskkill timedlocator
ERROR: Invalid argument/option - 'timedlocator'.
Type "TASKKILL /?" for usage.
currently using a runner script that boots up the batch file every 15 Sec (testing)
it wont close the batch script however
ive tried
taskkill/im cmd.exe
and
taskkill/im timedlocator.bat
the timedlocator gives the error, and the cmd closes the runner script aswell
that needs to reboot it, i cant seem to shutdown a specific cmd window without closing the other one, one solution ive tried is to make this timer shutdown script VBS and use this to shutdown CMD all together before rebooting it, but i dont know anything about what commands to use in VBS
original post
so basically i have a script that scans a area in pokemon go, unfortunately its about as unstable as it gets, so to fix this i need to reboot it about every 15 minutes, ive already tried a few things but got stuck in the end because im not very familiar with coding,
the original boot script script:
#echo off
set /p UserInputPath= Set Location-
C:\Python27\python main.py -u name -p pass -l "%UserInputPath%"
this calls the actual program that does all the work, after some research i found this How do I create a batch file timer to execute / call another batch throughout the day
and added this into the start of the script
start timer.bat
this opens a 2nd script to close and reboot after a timer
TIMEOUT /T 15 /NOBREAK
taskkill timedlocator
start timedlocator.bat
this leaves me with 2 problems i have not been able to figure out
how do i close the first batch without closing the timer CMD? ive tried messing around with taskkill and closing cmd alltogether, but this makes it impossible to boot it again
how do i automatically input a fixed streetname into the first file?
i have tried to replace the userinputpath with the streetname but that didnt seem to work.
setlocation-
at which point you enter a streetname, it sends this to the locator and it starts working,
what im trying to achieve is bypassing this first step and always send the same name.
any help with this would be much appreciated, ive been messing around w this for about 2 hours now and i have made some progress but ive seemed hit a dead end here with my limited computerskills
not sure of you're asking, but I'll try to answer anyway:
how do i close the first batch without closing the timer CMD? ive tried messing around with taskkill and closing cmd alltogether, but this makes it impossible to boot it again
You're taking it the wrong way round: create a script called runner.bat for instance and put this (untested)
:loop
start timerlocator.bat
timeout /T 900 /NOBREAK
taskkill /F /IM "python.exe"
goto loop
Your main script is started in background, and is killed and relaunched every 15 minutes (your 15 value is wrong timeout needs seconds).
how do i automatically input a fixed streetname into the first file? i have tried to replace the userinputpath with the streetname but that didnt seem to work.
=> remove the /P option and set the real value.
set /p UserInputPath=type_your_value_here
Related
Hope I'm in the right place here, wasn't sure where to post and this seemed the most likely
I use a cmd box to run a serial flasher program for repairing wifi boards, the way it works is this.
open a command prompt and change to the working directory
enter the command
sfh_DM36x.exe -nandflash -v -p "COM3"
this starts the flashing program, however, due to the way it works, the program when finishing the first time just loops with bootme bootme, this is normal behavior.
Normally I just hit CTRL+C and exit the batch file.
The same command is run again and this time the flashing process completes and you are returned to the C:\ prompt.
Now you have the information here is what I am trying to achieve.
Launch a batch file that runs the runflash.bat, kill the runflash.bat and then run runflash.bat again.
So far I have gotten as far as this (start.bat)
start c:\users\jud\desktop\runflash.bat
timeout /t 5
This runs a new CMD prompt and opens the runflash.bat
I've then entered a timeout of 5 seconds (long enough for the first attempt to finish)
at this point, I wanted to kill the currently open CMD prompt and then execute runflash.bat again.
at this point I'm stumped, any attempt to kill the second CMD prompt just kills the original, I've looked at taskkill but the PID changes each time I run the script, as well as other suggestions I've come across during google searches, most just relate to killing batch files manually or killing a CMD prompt where a batch file has finished.
Can this be done, the idea is to pass the file out to users who aren't familiar with CMD prompt workings as an all in one solution.
Provide the new process with a unique title (see start /? - the first quoted parameter is set as a title). Takskkill can then identify and close the process with its title:
start "JudRunFlash" "c:\users\jud\desktop\runflash.bat"
timeout /t 5 >nul
taskkill /fi "WindowTitle eq JudRunFlash"
cd "..\..\..\Sound"
start "" "mt32.exe"
timeout /T 5 /nobreak > NUL
cd ".\"
SCIV.exe
If you are at all familiar with DOSBox, I'm using a DOSBox fronted (D-Fend Reloaded) to launch a .bat which contains this code. What's supposed to happen is this:
The batch file changes directory and launches mt32.exe (which is an autohotkey script that opens up a MT-32 synthesizer)
The batch file waits for 5 seconds
The batch file then changes to its own directory and launches SCIV.exe (which is the exe for the game Space Quest III
What actually happens is that after starting mt32.exe, it blows right past the the timeout command and starts the game. I wonder if D-Fend Reloaded (the frontend) is pre-loading the batch file and executing it on its own terms or something?
Anyways, I'm wondering if there's any way I can actually enforce the timeout and make sure that it occurs before the game is launched; it's fairly critical. The point is to make sure that the mt32 synth has enough time to fully initialize before the game starts.
This may work:
ping 127.0.0.1 -n 6 >nul
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 want to make a automated program in .bat. The program needs to run a command. However, the command must be run from a custom CMD.
If I open a regular CMD, the commands that I will do:
C:\Hardware\bin\StartCustomCMD.bat init (This is the first thing I will type. It starts the custom CMD.)
bb autobuild (This is the second thing that I will type. The command goes into the custom CMD)
You can probably tell that I did not write these scripts. I am trying to set this up in Windows Scheduler so that the script gets run automatically every day. Any help on how can I do that?
Thanks.
Make yourself a new batch file, and embed the other things into it, and then run that.
#echo off
call C:\Hardware\bin\StartCustomCMD.bat
bb autobuild
If bb it itself a batch file, then use call on it also. What call does is execute another batch file, and then continue processing. If you don't use call, when you run one batch file from another, the latter 'takes over' and the caller does not continue.
To do this you can use the timeout and goto command. Timeout waits a period of time in seconds but it can be skipped by pressing any key while cmd is open at the top layer. If you can see cmd press its icon on the desktop until you can not see it. Then using the goto command you can go to the top line. So here would be your script:
:start
C:\Hardware\bin\StartCustomCMD.bat init
bb autobuild
timeout 86400
goto start
You already know what the first two commands do, but timeout 86400 waits exactly one day then the goto start command goes to the first command so that gets repeated. If you need to add any more commands then put them above the timeout 86400 command.
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?