Jump to content
LaunchBox Community Forums

Windows 11 - "Auto Sleep" Startup Application


Recommended Posts

Features:

  • Automatically shut off the console after a N-Minutes of inactivity.
  • It will listen for any Keyboard or Controller input.
  • Once activity is found, the app is paused of N-minutes.

Here's a gotcha, though. Windows requires permission to run the shutdown command. If you're running as admin, I think you're fine. If not you'll need to give your user permission...

  1. Open the Local Security Policy editor by typing "secpol.msc" in the Start menu search box and pressing Enter.
  2. In the Local Security Policy editor, navigate to Local Policies > User Rights Assignment.
  3. In the right-hand pane, double-click the "Shut down the system" policy.
  4. In the "Shut down the system Properties" window, click the "Add User or Group" button.
  5. In the "Select Users or Groups" dialog box, type your user name in the "Enter the object names to select" field and click "Check Names" to confirm the user name.
  6. Click OK to close the "Select Users or Groups" dialog box, and then click OK to close the "Shut down the system Properties" window.
  7. Close the Local Security Policy editor.

Attached is the C++ Code and the compiled code.

Usage: `AutoSleep.exe <minutesAllowedInactive> <pauseMinutesBetweenActivity>`

Example usage: `AutoSleep.exe 120 45`

Everything should work out of the box, but I'm not normally writing C++ Code... or working within Windows for that matter. I welcome any changes or updates. I am placing this in beta and keeping it there.

AutoSleep.exe autosleep.cpp

  • Like 1
Link to comment
Share on other sites

  • 3 months later...
  • 1 month later...

Just a quick tip, to give Windows permission to run the shutdown command, you can follow these steps:1. Press the win key on your keyboard. 2. Type "secpol.msc" in the search box and hit Enter. 3. In the Local Security Policy editor, go to Local Policies > User Rights Assignment. 4. Double-click the "Shut down the system" policy in the right-hand pane. 5. Click the "Add User or Group" button. 6. Type your username in the field and click "Check Names" to confirm. 7. Click OK to close the dialog boxes and close the editor. Hope this still helps someone here, guys. Sometimes, getting a new windows key may be helpful too.

Edited by ShelbyHughes
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...