Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 1. Install nssm.exe
- 2. Copy C:\Program Files\Python38\Lib\site-packages\pywin32_system32\pywintypes38.dll
- as C:\Program Files\Python36\Lib\site-packages\win32\pywintypes38.dll
- 3. Create this file, "D:\scripts\gsBatteryLog.py"
- #################################################
- import os, re, datetime, time
- counter = 0
- while True:
- if counter % 60 == 0:
- file = open( "D:/scripts/.gsBatteryLog.txt", "a" );
- output = os.popen( "wmic Path Win32_Battery Get EstimatedChargeRemaining /Value" ).read()
- percent = re.compile( r"[^0-9]", re.MULTILINE ).sub( "", output )
- file.write( datetime.datetime.now().isoformat() )
- file.write( " " )
- file.write( percent )
- file.write( "\n" )
- file.close()
- time.sleep( 5 )
- counter = counter + 1
- #################################################
- 4. Install and start service
- > nssm.exe install GSBatteryLog "C:\Program Files\Python38\python.exe" D:\scripts\gsBatteryLog.py
- 5. Buka "services.msc" dan Start service "GSBaterryLog"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement