Using of script file to finish/upload and shutdown windows
Posted: Mon Apr 27, 2020 2:29 pm
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
Monday.bat
MondaySendKeys.vbs
Friday.bat
FridaySendKeys.vbs
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:
Happy folding .
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
Code: Select all
set OBJECT=WScript.CreateObject("WScript.Shell")
WScript.sleep 5000
OBJECT.SendKeys"unpause{ENTER}"
WScript.sleep 5000
OBJECT.SendKeys"exit{ENTER}"
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
Code: Select all
set OBJECT=WScript.CreateObject("WScript.Shell")
WScript.sleep 5000
OBJECT.SendKeys"finish{ENTER}"
WScript.sleep 5000
OBJECT.SendKeys"exit{ENTER}"
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:
/EDITPantherX 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.
Happy folding .