Solved Need help with %time%, open and reopen a program at midnight

October 26, 2012 at 15:51:53
Specs: Windows 7
Hello everyone,
I'm new here but this seems to be the perfect webstie to ask this question as i've been trying to get this question answered for a long time.

What I want the batch to do:
Well the batch file is for a program that bots my account on a game, so all it does is open and close the bot when the bot turns off by itself.
Now the problem is at midnight the game freezes, so this means my bot does nothing has the game freezes you can't walk or do anything on the game, so I want the batch file to check for the time every so often and make sure that at midnight it closes the bot and then re-opens it.
Have a look at my code all I need help with is adding the time to make it close and re-open at midnight.

My code:

@echo off
cls
echo @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
echo @ EOBot Protecting Crashes @
echo @ @
echo @ By Exile @
echo @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
echo
echo Protecting EOBot from crashes...
echo If you wish to close EOBot and this batch, close the EOBot window and type Y depending on your language followed by Enter.
title EOBot Crash Protection By Exile
:EOBot
echo (%time%) EOBot started.
start /wait EOBot.exe
echo (%time%) WARNING: EOBot closed or crashed, restarting.
goto EOBot


See More: Need help with %time%, open and reopen a program at midnight

Report •

✔ Best Answer
October 27, 2012 at 05:53:19
Now its done and work great. There are several ways to do the same thing
time /t >%temp%\aa.txt
set /p aa=<%temp%\aa.txt
if %aa%==00:00 echo its midnight

and other ways i can remenber, this was just air code, but any way , thanks it was a valid and helpful contribute.



#1
October 26, 2012 at 16:32:35
Yes, because cheating in on line games is exactly what we want to support. Points for honesty, though.

How To Ask Questions The Smart Way


Report •

#2
October 26, 2012 at 16:32:40
Hi , thats easy as killing rabbits...I didnt test it cause it passes from midnight but im preaty shure that works. It makes a ping, to program wait 5 seconds, its better to dont stress your computer if you are using win7 replace the ping line to timeout /t 5

@echo off
title ==Home Made== http://batch.csproject.org
:ab
echo.
echo %time% Waiting for midnight..
ping 127.0.0.1 -n ^6 >nul
echo %time%>%temp%\784dh.txt
findstr /L "00:00" %temp%\784dh.txt
if not errorlevel 1 goto aa
goto ab
:aa
taskkill /IM EOBot.exe /F
start EOBot.exe
goto ab


Report •

#3
October 26, 2012 at 16:53:51
RogerSmith when you said to change the ping line to timeout /t 5 did you mean this line?

''ping 127.0.0.1 -n ^6 >nul''

Also does that script you just put there do everything that my script did before + the time that I asked? Because on my old script if I closed the bot a message would come up saying to put Y if I was sure that I wanted to close it or N if I didn't wanna close it.

Also this line ''indstr /L "00:00" %temp%\784dh.txt'' does the ''00:00'' stands for midnight? If I changed it to 01:00 would it close and re-open at 01:00 instead of midnight or would it f--- up the script?

I'll give it a shot later though thank you for the help.


Report •

Related Solutions

#4
October 26, 2012 at 18:03:59
"Also this line ''indstr /L "00:00" %temp%\784dh.txt'' does the ''00:00'' stands for midnight? If I changed it to 01:00 would it close and re-open at 01:00 instead "

Yes it will change the hour
__________________________//____________________________

"when you said to change the ping line to timeout /t 5 did you mean this line?"
''ping 127.0.0.1 -n ^6 >nul''

Yes all that line for timeout /t 5 , but only if you are using win7

_______________________//__________________________

"Because on my old script if I closed the bot a message would come up saying to put Y if I was sure that I wanted to close it or N if I didn't wanna close it."

i dont realy understand what is the propose of that , is to restart the bot if you close it? i will assumpt that yes and code it again
_______________//__________________________________
You may now forget the last script and the ping crap let it be as it is.
I add user output , configure yourself the hour every time that you run the script , and i add the automatic mode, you can turn it on and what it does is , if the bot closes because of any thing , the script will re-open it.
I add that option when you close the bot the script will ask you if you want to open it again.
I didnt test it but i think that is every thing ok , i code derty because make part of who iam so if you dont understand the code dont worry. just make shure that you put this batch file in the same directory as the EOBOT.exe

@echo off
title ==Home Made== http://batch.csproject.org
:acc
cls
echo Enter hour to close and re-open bot [eg. 00:00]
set /p jhg=
echo Do you want automatic mode [^If the bot close it will be Re-open] (y/n) ?
set /p kjhy=
if %kjhy%==y goto zs
if %kjhy%==yes goto zs
:ab
cls
echo.
echo %time% Waiting for bot actions at %jhg%...
tasklist | findstr /l EOBot.exe>%temp%\784dh.txt
findstr /l "EOBot.exe" %temp%\784dh.txt
if errorlevel 1 goto abc
ping 127.0.0.1 -n ^6 >nul
echo %time%>%temp%\784dh.txt
findstr /l "%jhg%" %temp%\784dh.txt
if not errorlevel 1 goto aa
goto ab
:aa
taskkill /IM EOBot.exe /F
start EOBot.exe
goto ab
:abc
cls
Echo.
Echo It seem that EOBot was terminated do you want to Re-open it?(y/n)
set /p hgs=
if %hgs%==n exit
if %hgs%==no exit
if %hgs%==yes goto fdl
if %hgs%==y goto fdl
goto abc
:fdl
start EOBot.exe
goto acc
:zs
cls
echo.
echo %time% Waiting for bot actions at %jhg%...
tasklist | findstr /l EOBot.exe>%temp%\784dh.txt
findstr /l "EOBot.exe" %temp%\784dh.txt
if errorlevel 1 goto aa1
ping 127.0.0.1 -n ^6 >nul
echo %time%>%temp%\784dh.txt
findstr /l "%jhg%" %temp%\784dh.txt
if not errorlevel 1 goto aa1
goto zs
:aa1
taskkill /IM EOBot.exe /F
start EOBot.exe
goto zs

I edited this post at 18:03:59 Pacific
if you read this is because the script works well and you are good to go


Report •

#5
October 26, 2012 at 19:15:12
If all else fails, just set up a "at" job to run at midnight and kill the bot. Your original script will handle restarting it. (should work as long as your computer's clock is reasonably accurate). My philosophy, regarding bots, is if you write it yourself, you're playing "dirty" but at least you're honing your computer skills. If you buy a bot, you're wasting your money anyway. The sys-ops will keep changing the game.

Report •

#6
October 27, 2012 at 04:18:30
Use this:
@echo off
if "%time:~0,-9%"=="00" (
echo. Time is midnight!
pause > nul
exit /b
)
To determine how long you have to wait for midnight you'd have to mess with substrings and find how much you'd need to sleep before checking again.

Report •

#7
October 27, 2012 at 05:53:19
✔ Best Answer
Now its done and work great. There are several ways to do the same thing
time /t >%temp%\aa.txt
set /p aa=<%temp%\aa.txt
if %aa%==00:00 echo its midnight

and other ways i can remenber, this was just air code, but any way , thanks it was a valid and helpful contribute.


Report •

Ask Question