How do I create a power request? (not override)  


  1. Posts : 116
    Win 10x64 Pro
       #1

    Stop Monitor from going to sleep while playing Fallout 4


    Here's the deal.

    For some reason, when I play Fallout 4 (only Fallout 4) if I leave pc idle long enough for my monitor to go to sleep, when it does the PC becomes totally unresponsive requiring a hard reset. I can still hear the game sounds.

    The monitor used to sleep and wake normally if I left the game running. The system does not go to sleep while the game is running though.

    I know how to create a "requestoverride" to prevent things from keeping the PC from sleeping (which I have none of) but how do I create a "request" to prevent the display from sleeping when the fallout4.exe process is running?

    The possible cause of this issue may be the fact that I did not "install" the game. I had previously created a single archive of the entire game, files and folder structure, and I restored that back to it's original logical location.

    The reason for doing this is the massive amount of modding I've done and continue to do to the game. When I have it all running with no problems, I make a backup. I may remove it for 6 months then come back and restore it and do another round of heavy modding and it's good to have a backup in case things go wrong, which they often do when running over 160 mods, using custom models and physics, and teaching yourself how to mod the game even deeper.

    Windows 10 x64 Pro V1803 Build 17134.345
    Last edited by Sqrly; 10 Nov 2018 at 15:24. Reason: Was trying to use wrong method to solve issue.
      My Computers


  2. Posts : 809
    Win10
       #2

    This is a very simple thing if you can compile programs for Windows. Just call SetThreadExecutionState(ES_DISPLAY_REQUIRED) in your language of choice.

    If not, then you can use this PowerShell script: https://blog.backslasher.net/windows-awake-ps.html

    Just change the line from
    Code:
    Suspend-Powerplan {Read-Host 'press enter to terminate'}
    to
    Code:
    Suspend-Powerplan {Read-Host 'press enter to terminate'} -option Display
    You will see:

    Code:
    PS C:\WINDOWS\system32> powercfg /requests
    DISPLAY:
    [PROCESS] \Device\HarddiskVolume4\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
      My Computer


  3. Posts : 116
    Win 10x64 Pro
    Thread Starter
       #3

    No, I can't "compile programs". If I could, I wouldn't be using windows.

    That code appears to keep the PC from sleeping when powershell is running? Not at all what I'm looking for. Besides, I can just change the power settings with a few clicks.
      My Computers


  4. Posts : 809
    Win10
       #4

    The Powershell script is creating a request to prevent the display from sleeping, which is what you wanted, right? Just run the script at the same time you launch Fallout4.

    I know how to create a "requestoverride" to prevent things from keeping the PC from sleeping (which I have none of) but how do I create a "request" to prevent the display from sleeping when the fallout4.exe process is running?
    Code:
    PS C:\WINDOWS\system32> powercfg /requests
    DISPLAY:
    [PROCESS] \Device\HarddiskVolume4\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
      My Computer


  5. Posts : 14,868
    Windows 10 Home x64 Version 22H2 Build 19045.2965
       #5

    You could replace the shortcut you use to run the game with a shortcut to a batch file containing

    Code:
    :: Set sleep never
    powercfg /change standby-timeout-ac 0
    powercfg /change standby-timeout-dc 0
    :: Run the game
    Call {whatever is in your normal shortcut's properties to start the game}
    :: Pause during testing to make sure this line is not reached until the game ends
    :: Set sleep back to normal [I have used 1 min in this example]
    powercfg /change standby-timeout-ac 1
    powercfg /change standby-timeout-dc 1
    You would have to test the batch file to make sure that the game behaved itself when started using Call [hence the remarked out line :: Pause during testing].
    I have seen some things misbehave and unexpectedly pass control straight back to the batch file as soon as the Call command runs with the result that the final batch file commands are executed straightaway instead of after the game is closed. If this does happen you'd need to experiment with using a Start command instead of Call.

    Notes
    1 The batch file shortcut's icon would be visible on the Taskbar all the time the game is running. I suggest making the shortcut run minimised.
    2 You could set the shortcut's icon to the same as that used for the game so you'd know what it was.

    3.1 If you really hate the idea of the batch file's shortcut being on the Taskbar the whole time you could either use vbs instead of the batch file or use the vbs to call the batch file.
    3.2 In both cases, you would write the vbs to run the individual powercfg commands / batch file in a hidden window [this would hide the individual powercfg commands / batch file but should not hide the game's window].
    3.3 I find using vbs to run the whole batch file to be the easiest method but that is only because my vbs skills are so poor.
    Code:
    Set WshShell = CreateObject("WScript.Shell")
    WshShell.Run chr(34) & "C:\Tools\StartTheGame\StartTheGame.bat" & Chr(34), 0


    Best of luck,
    Denis
      My Computer


  6. Posts : 116
    Win 10x64 Pro
    Thread Starter
       #6

    Try3 said:
    You could replace the shortcut you use to run the game with a shortcut to a batch file containing

    ….Best of luck,
    Denis
    Ok, this is a viable solution but... I still had one complication. Your reply got the neurons firing and I was able to figure it out. I love it when people focus on the solution and not on the problem.

    The executable for this game is "fallout4.exe" but, I do not start the game using that executable. I start the game using the Fallout 4 Script Extender or "f4se_loader.exe" which ends after starting fallout4.exe and was making the bat go to the last line and close.

    Pinning it to the Win 10 start menu and customizing the tile is a whole other discussion but it's easy enough to do.
    Code:
    :: This sets the monitor to never sleep.
    powercfg /change monitor-timeout-ac 0
    ::
    :: This starts fallout4.exe via f4se_loader
    c:\windows\system32\cmd.exe /c start /wait "" "C:\Games\FO4\Fallout 4\f4se_loader.exe"
    ::
    :: This starts a loop that checks if fallout4.exe is running every 30 seconds. When fallout4 is no longer the loop ends.
    SETLOCAL EnableExtensions
    set EXE=Fallout4.exe
    :LOOPSTART
    FOR /F %%x IN ('tasklist /NH /FI "IMAGENAME eq %EXE%"') DO IF %%x == %EXE% goto FOUND
    goto FIN
    :FOUND
    TIMEOUT /T 30
    goto LOOPSTART
    :FIN
    :: This sets Monitor sleep back 5 minutes 30 seconds after you close the game.
    powercfg /change monitor-timeout-ac 5
      My Computers


  7. Posts : 14,868
    Windows 10 Home x64 Version 22H2 Build 19045.2965
       #7

    I'm glad to have loaded your neurons.

    Denis
      My Computer


 

  Related Discussions
Our Sites
Site Links
About Us
Windows 10 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 10" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 21:59.
Find Us




Windows 10 Forums