Page 1 of 1

Using of script file to finish/upload and shutdown windows

Posted: Mon Apr 27, 2020 2:29 pm
by Zangetsu
If you're like me , and have a reason to shutdown the PC after it's done with folding, when you've finished uploading the WU to the server, this is how i do it:
My reason is that i have PV-panels, and have a surplus on the day-counter of electricity , but have to little reserve on the night-counter.
I'm using windows 10, (EDIT) and FAHclient 7.6.9
I make use of the Task manager, make sure your tasks are set to configure to "win 10".
If you want to do an auto awaken after hibernate/shutdown make sure you set it in the BIOS that it's enabled + set the task so that i may awaken the pc to do the task (admin rights needed).

Anyway to the code , I'm using this as my Monday/Friday switch in order to finish the work , upload it , and then hibernate the pc. Since i don't know when the WU will be finished/ done with uploading.
I can't set a time on when it will be ready, and i can only set it so that it won't start new WU on a certain time , for me this is 20:00. (setting in the task manager)
The start timing of the .bat files are done in the task scheduler.
So that it can restart again on Monday 6AM and get the Monday.bat command at 6:02 AM to restart the folding.

the out-hibernate-start command is being done by the Task Scheduler.

I am using a hibernate.bat on Monday -Thursday evening , only Friday evening and Monday morning is special because of the weekend , and i don't wanna timeout the WU because of that.


Hibernate.bat

Code: Select all

timeout 10
shutdown /h

Monday.bat

Code: Select all

start telnet localhost 36330
cd C:\Users\%username%\Desktop\end before hibernate
cscript MondaySendKeys.vbs
MondaySendKeys.vbs

Code: Select all

set OBJECT=WScript.CreateObject("WScript.Shell")
WScript.sleep 5000
OBJECT.SendKeys"unpause{ENTER}"
WScript.sleep 5000
OBJECT.SendKeys"exit{ENTER}"
Friday.bat

Code: Select all

start telnet localhost 36330
cd C:\Users\%username%\Desktop\end before hibernate
cscript FridaySendKeys.vbs
:top
timeout 30
tasklist /FI "IMAGENAME eq FAHCoreWrapper.exe" 2>NUL | find /I /N "FAHCoreWrapper.exe">NUL
if not "%ERRORLEVEL%"=="0" goto ending
goto top
:ending
:filetest
IF NOT EXIST "C:\Users\%username%\AppData\Roaming\FAHClient\work\00\wudata_01.dat" (IF NOT EXIST "C:\Users\%username%\AppData\Roaming\FAHClient\work\02\wudata_01.dat" (IF NOT EXIST "C:\Users\%username%\AppData\Roaming\FAHClient\work\02\wudata_01.dat" (IF NOT EXIST "C:\Users\%username%\AppData\Roaming\FAHClient\work\03\wudata_01.dat" (IF NOT EXIST "C:\Users\%username%\AppData\Roaming\FAHClient\work\02\wudata_04.dat" (IF NOT EXIST "C:\Users\%username%\AppData\Roaming\FAHClient\work\05\wudata_01.dat" goto hiber)))))
timeout 30
goto filetest
:hiber
timeout 30
shutdown /h
FridaySendKeys.vbs

Code: Select all

set OBJECT=WScript.CreateObject("WScript.Shell")
WScript.sleep 5000
OBJECT.SendKeys"finish{ENTER}"
WScript.sleep 5000
OBJECT.SendKeys"exit{ENTER}"
If you want to shutdown the PC instead of hibernate , change the "shutdown /h" to "shutdown /s"
timeout is in sec
WScript.sleep is in milisec.
EDIT:
The amount of WU-slots that need to be checked are #GPUs X2 =Max slots.
So for me it will be max 6 (starting from 00 to 05) for 3 GPUs
Code was also edited to reflect this
/EDIT
The scripts are on the desktop in a map "end before hibernate", but can be rewritten to be placed where you like.
I have to work with a SendKeys command to the telnet server, the timings are a bit large but are to make sure there is an connection before issuing an command. (<= if anyone know a better way pls let me know how to send commands to the already running FAHclient)
The downside of this way is that i don't know for sure if the command(telnet) executed successfully (telnet is a different window then the cmd window)

The scripts works with command thru the Telnet service, and the test is being handled by the cmd.
It first test every 30 sec that all instances of the "FAHCoreWrapper.exe" are done (active folding), then it tests if a work file still exists in the map C:\Users\%username%\AppData\Roaming\FAHClient\work\
It tests for this file because after the upload , the work files are deleted by the FAHclient, and this can be easily detected by a cmd script (no files/workfiles of the FAHclient are being modified by this script.)
Make note that for every GPU you have , the number changes in a logical way (00-01-02-03-04-...)
You can expand the file probe with more "if tests" if you have more GPU's running.

EDIT:
PantherX wrote: I had a quick look at the scripts and since you're not using FahCore_22 anywhere, it will work on CPU Slots too.

Another "fail-safe" option I would suggest is that you limit how many WUs your system will fold at any given time. Reason is that for 3 GPUs, you only check 6 folders (assumption is 1 GPU has 2 WUs) but if there are network issues, it can be a lot more than 6 folders. Thus you can use this setting in the client to ensure that it only does X number of WUs which is in line with how many folders you check:

Code: Select all

  max-units <integer=0>
    Process at most this number of units, then pause.
/EDIT

Happy folding :D .

Re: Using of script file to finish/upload and shutdown windo

Posted: Mon Apr 27, 2020 4:09 pm
by Rel25917
Little problem, work folders start at 00 and go up(and back down) for a single slot it starts with 00, when that unit is finishing the next unit is downloaded and will be 01, when 01 is finishing the next unit will go back to 00. If a unit fails to upload that number stays in use until the unit is gone and it will use 02 then 03 and so on as needed but will always go back to the lowest available number for the next unit. You not looking for 00 in your script. It sounds like you think the work folders are tied to a specific slot, they aren't. If you are running 3 slots(guessing based on your script) you can go through 6 or more work folders easy.

Re: Using of script file to finish/upload and shutdown windo

Posted: Mon Apr 27, 2020 4:30 pm
by Zangetsu
Rel25917 wrote:Little problem, work folders start at 00 and go up(and back down) for a single slot it starts with 00, ..., If you are running 3 slots(guessing based on your script) you can go through 6 or more work folders easy.
Thank you for the feedback , I'll update the script to be with 6 slots, and I'll include it in the main post to reflect the input
Rel25917 wrote: If a unit fails to upload that number stays in use until the unit is gone and it will use 02 then 03 and so on as needed but will always go back to the lowest available number for the next unit.
The script is made so ensure the shutdown of the PC is done after the upload.
If you'd want to shutdown the PC after a certain time has passed whether the upload has been done or not, you can set it by the Task schedule.
Don't forget to tick the box off "Run this task as soon as possible after a scheduled start is missed"

Re: Using of script file to finish/upload and shutdown windo

Posted: Tue Apr 28, 2020 2:57 am
by PantherX
I had a quick look at the scripts and since you're not using FahCore_22 anywhere, it will work on CPU Slots too. Folders for Work Units are created in the same manner for both CPU and GPU and the contents are similar too so it should work.

Another "fail-safe" option I would suggest is that you limit how many WUs your system will fold at any given time. Reason is that for 3 GPUs, you only check 6 folders (assumption is 1 GPU has 2 WUs) but if there are network issues, it can be a lot more than 6 folders. Thus you can use this setting in the client to ensure that it only does X number of WUs which is in line with how many folders you check:

Code: Select all


  max-units <integer=0>
    Process at most this number of units, then pause.