1

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

Community
  • 1
  • 1

1 Answers1

1

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
Jean-François Fabre
  • 137,073
  • 23
  • 153
  • 219
  • the second part about the /p works great, the only problem with closing the python is that it does not reboot without also rebooting the CMD. normally all i need to do to reset is, reboot the cmd and the python will continue to do its work in the background – Rick Pijnenburg Jul 20 '16 at 10:49
  • One down, one to go :) but I'm lost here. What do you want to kill exactly? which process has a problem? the pokemon go process? ran by which parent process? – Jean-François Fabre Jul 20 '16 at 10:55
  • Rebooting the first batch file will cause the parent program to reboot aswell, this is what im trying to do. the problem is that, the python file gets its info from the pokemon go server, which is instable causing one of the programs (the batch or python) to glitch out, the easyest way to fix this is by simply rebooting both by rebooting the first batch file – Rick Pijnenburg Jul 20 '16 at 10:58
  • ive tried doing this but this has the same problem, it wont shutdown the script – Rick Pijnenburg Jul 20 '16 at 11:56
  • in that case, kill the python process, that will terminate the script. BTW the `taskkill` command syntax is strange. I use `/IM` to kill a process given it's name: `taskkill /IM "python.exe"` – Jean-François Fabre Jul 20 '16 at 12:21
  • and `TIMEOUT /T 15` actually waits 15 seconds not 15 minutes. I have edited my post to reflect my 2 latest comments. – Jean-François Fabre Jul 20 '16 at 13:45
  • yea i figured this out aswell, but i put it on a low time so i could test it without actualy waiting for 15 mins – Rick Pijnenburg Jul 20 '16 at 20:18