Putting a Windows 10/11 computer to sleep over the network using SSH.


Recommended Posts

So I have a little Lenovo computer I got off eBay for the sole purpose of displaying my security cameras above my TV. It's a Pentium with 4GB of ram and uses around 11 watts. But I don't need it awake and running at night when I'm sleeping or out of the house.

I was looking for a way to put it to sleep remotely because there is no mouse and keyboard hooked up to it. I found a way to do it via SSH. Install OpenSSH on the computer, install putty on my computer, and create a batch file which when ran, connects to the SSH server using putty and sends the following sleep command.

 RUNDLL32.EXE powrprof.dll,SetSuspendState

The Bat file looks like this

putty.exe -ssh owner@IP address -pw Password -m c:\command.txt

You replace the ip address with the ip address of the computer and the password with the password of the computer. Then just put the rundll command above in the command.txt.

Then to wake it up I simply use a wake-on Lan app. I was surprised how well it worked on my first attempt, which can be seen in the video below.

11 watts isn't much, but a little here and a little there and it adds up.

  • +Warwagon changed the title to Putting a Windows 10/11 computer to sleep over the network using SSH.
  On 09/02/2023 at 16:08, Warwagon said:

11 watts isn't much, but a little here and a little there and it adds up.

Expand  

Yeah to the tune of what about 65 cents a month, if you leave it off for 16 hours a day and elec costs you like 12 (national average or so) cents a kwh.. So what 8$ in a year - you could buy yourself a starbucks coffee ;) heheh

But its not fully off is it, so are you really saving the whole 11 watts or is it something less than that your saving? ;) I am all for saving electric and all - but is the say 2 cents a day worth it if something fails and it doesn't come back up when you want to see whats on the camera? ;)

  On 09/02/2023 at 20:05, BudMan said:

Yeah to the tune of what about 65 cents a month, if you leave it off for 16 hours a day and elec costs you like 12 (national average or so) cents a kwh.. So what 8$ in a year - you could buy yourself a starbucks coffee ;) heheh

But its not fully off is it, so are you really saving the whole 11 watts or is it something less than that your saving? ;) I am all for saving electric and all -

Expand  

I'm just a tightwad who also hates wasting electricity.  Also my elec cost is 8 cents for the first 1,000 kw then it goes down to 4 cents. At least during the winter.

So, get this, I just put all 4 of my couch computer monitors on a surge protector connected to a voice-controlled outlet. So at night, I say "Ok, Google, turn off the monitors" and the combined sleep of all 4 monitors which was 3 watts, is now 0 :) (I put a kill-a-watt on it)

But I can also tell them to turn off when i'm down stairs in my office, not even on the couch computer. In that case it saves 180 watts

So now we are up to about 13 watts! woot! (little computer is probably burning 1 watt just to sleep.

As per the last bit, the computer gets turned on when I wake up in the morning and get turned off when I go to bed.

  • Like 1
  • Love 1
  On 09/02/2023 at 20:26, BudMan said:

4 cents per kwh?  JFC that is cheap.. So your saving what like $2.5 a year.. Not even enough for a coffee ;)

Expand  

 

  On 09/02/2023 at 20:26, BudMan said:

4 cents per kwh?  JFC that is cheap.. So your saving what like $2.5 a year.. Not even enough for a coffee ;)

Expand  

Its enough for a Tim Hortons coffee... lol

  • Haha 1
  On 09/02/2023 at 23:18, Matthew S. said:

Its enough for a Tim Hortons coffee... lol

Expand  

I think that's almost enough for Dunkin' if I remember right..

I would be more interested in this 4 cents you say your paying, or even 8 cents .  So if you go over 1000 kwh for the month the rate drops to 4 cents?  That is some cheap power to be sure, prob not much solar in your area at those rates.

Do they hit you with high delivery charges?  This is what can be confusing in finding true cost of power in some areas - where sites will list the cost per kwh, they don't always show the delivery charges..

Here in chicagoland the price per kwh is only like 9 some cents.. But then they add on another like 4 cents for delivery of that electric per kwh.  And then there is just the charge for being a customer, and the meter charge..

Hope my jokey way of responding didn't come across that not worth saving some kwh here or there.. But there is prob some bigger fish to fry in saving electric than something that only uses like 10 watts..  And shutting it down for a few hours a day.

How long do you leave it off vs on is needed to know how much actual kwh you might be saving as well.

 

 

 

 

 

  On 11/02/2023 at 05:36, BudMan said:

I would be more interested in this 4 cents you say your paying, or even 8 cents .  So if you go over 1000 kwh for the month the rate drops to 4 cents?  That is some cheap power to be sure, prob not much solar in your area at those rates.

Do they hit you with high delivery charges?  This is what can be confusing in finding true cost of power in some areas - where sites will list the cost per kwh, they don't always show the delivery charges..

Here in chicagoland the price per kwh is only like 9 some cents.. But then they add on another like 4 cents for delivery of that electric per kwh.  And then there is just the charge for being a customer, and the meter charge..

How long do you leave it off vs on is needed to know how much actual kwh you might be saving as well.

Expand  

image.png.10f1aee4aa2553f68a37b2a526686f68.png

I forgot, that there is also the Energy Adjustment Clause, where they adjust what the have to pay. I have no gas and just have heat pump. Usually during months were the heat or ac doesn't have to run my electric bill is about $60.

  Quote

Hope my jokey way of responding didn't come across that not worth saving some kwh here or there.. But there is prob some bigger fish to fry in saving electric than something that only uses like 10 watts..  And shutting it down for a few hours a day.

Expand  

For sure, I've done best I could, even replacing computers with lower power ones that do the same thing.

But then I go and build a new computer more power hungry than the last one. But if ya want performance gotta use some power.

  On 10/02/2023 at 17:32, Warwagon said:

Do tell.

Expand  

It's funny, I just finished watching this video and then I saw this thread. There are some neat tips throughout the video, but he talks specifically about shutting down remote computers at 14:43:

 

you used 2782 Kwh in 1 month?  WTF dude..  That is insane.. I have never used that much even in the summer with the AC running like constantly since the wife likes it 67 degrees..

Here is old bill showing before went solar

beforesolar.jpg.dab08157af3ba7b1c4107e6c832b677e.jpg

You used like what I used in 2 months in summer with AC going full bore..

 

 

  On 11/02/2023 at 22:58, BudMan said:

you used 2782 Kwh in 1 month?  WTF dude..  That is insane.. I have never used that much even in the summer with the AC running like constantly since the wife likes it 67 degrees..

Here is old bill showing before went solar

beforesolar.jpg.dab08157af3ba7b1c4107e6c832b677e.jpg

You used like what I used in 2 months in summer with AC going full bore..

 

 

Expand  

Air conditioning is much cheaper than heat pump in the winter. We had a Lowe’s in the -20. . At that point the emergency heat kicks on and I’m using electric heat. Actually under 15° needs assistant from the emergency heat.

  On 11/02/2023 at 23:01, Warwagon said:

and I’m using electric heat.

Expand  

Ugghhh.. Yeah that would suck.. Good thing your rate over 1k is only 4 cents ;)

  On 09/02/2023 at 16:08, Warwagon said:
RUNDLL32.EXE powrprof.dll,SetSuspendState 0,1,0
Expand  

Please stop spreading incorrect information. Your 0,1,0 parameters here do nothing! It is undefined if this command will sleep or hibernate. You are lucky it does not just crash and burn.

 

  Quote
Expand  

See also:

Shutdown.exe on recent versions can hibernate but not sleep for unknown reasons. Use Powershell instead for sleep.

Edited by WndSks
  On 12/02/2023 at 22:04, WndSks said:

Please stop spreading bad information. Your 0,1,0 parameters here do nothing! It is undefined if this command will sleep or hibernate. You are lucky it does not just crash and burn.

 

See also:

Expand  

I can confirm the 0,1,0 are not needed. I found that command online from numinous sources, so I didn't think to modify it, but I did remove those numbers from the command and it still works. Removed the numbers from the command on the first post.

  On 12/02/2023 at 22:19, Warwagon said:

and it still works

Expand  

but it is still incorrect and the result is undefined. There is simply no way to correctly call this function with rundll32. You must p/invoke with powershell.

 

Something along the lines of

Add-Type -Assembly System.Windows.Forms
[System.Windows.Forms.Application]::SetSuspendState([System.Windows.Forms.PowerState]::Suspend, $true, $false)

(I did not test this but it should be close)

  On 13/02/2023 at 01:00, farmeunit said:

Why don't you just schedule it?

Expand  

Because I don't always go to bed at the same time. I also want to put it to sleep if I leave the house for the day.

It doesn't have to be an exact schedule.  Just set to midnight if you go between 10-midnight.  As for leaving the house, use IFTT.  Set up something on your phone like a geofence.  You could probably even tie it into Alexa, so when you say Goodnight, it turns it off.  And when you say something else it turns it on.  Of course that requires WoL or something like that.  Lots of ways to really do it, but you need to right combination or hardware.

Honestly, use a smart plug.  Problem solved.

  On 18/02/2023 at 23:52, farmeunit said:

It doesn't have to be an exact schedule.  Just set to midnight if you go between 10-midnight.  As for leaving the house, use IFTT.  Set up something on your phone like a geofence.  You could probably even tie it into Alexa, so when you say Goodnight, it turns it off.  And when you say something else it turns it on.  Of course that requires WoL or something like that.  Lots of ways to really do it, but you need to right combination or hardware.

Honestly, use a smart plug.  Problem solved.

Expand  

Smart plug is like yanking the power out of the wall while it's running. Honestly I'm really happy with this setup. It works perfect for what I need.

If you're just using it for viewing cameras and such, it doesn't really matter.  Especially with mostly solid state parts.  The only time it really matters if it's writing data because it could get corrupted.  Otherwise, it makes little to no difference.  That being said, you can automated the whole process before actually shutting off the plug.  Then you can have it return to the last power state once the plug is turned on.  I was just giving you options instead of focusing on one way to do it.

 

Home Assistant or several other options available.

  On 20/02/2023 at 20:45, farmeunit said:

If you're just using it for viewing cameras and such, it doesn't really matter.  Especially with mostly solid state parts.  The only time it really matters if it's writing data because it could get corrupted.  Otherwise, it makes little to no difference.  That being said, you can automated the whole process before actually shutting off the plug.  Then you can have it return to the last power state once the plug is turned on.  I was just giving you options instead of focusing on one way to do it.

Expand  

Ya, I could have the computer shut down at X time, and then set it so a smart outlet turn off. Or I can just double click a batch file 3 seconds before I get off the couch and go to bed.

I do shut the machine off when I leave for 3 or 4 days.

Thanks for the options though.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Posts

    • One of the worst Linux distros out there, it's so locked down you can't customize the desktop environment and they limit your choices of apps. It's like you play in their sandbox only. The revolving door never stops spinning with Elementary OS because users install it only to find out how restricted it is compared to to Windows so they end up leaving Linux altogether or switch to Mint or Ubuntu.
    • Precisely. Once this current generation of milquetoast pseudo-AI achieves 100% accuracy on the things we already know as a baseline, then perhaps it has a chance of advancing our knowledge on things we're still finding solutions for.
    • Nvidia App gets light theme, bug fixes, and support for more games by Taras Buria Nvidia has released a new update for the Nvidia App on Windows. Version 11.0.4 is now available with a few changes, such as automatic theme switching with light mode support, Windows Narrator support, fixed bugs, and optimal settings for 12 new games. With today's update, Nvidia App now supports light mode. You can switch between modes in settings or let the app follow the system settings (Windows still does not support automatic theme switching). To change the mode, go to Settings > Features > Theme. In addition, Nvidia App now supports Windows Narrator. The system's native screen reader can now properly read aloud on-screen content to improve accessibility for those relying on assistive technologies. Next, the list of games that Nvidia App can tune for optimal performance has been extended with 12 new titles: Assassin's Creed: Shadows Clair Obscur: Expedition 33 Deadlock ELDEN RING NIGHTREIGN Grand Theft Auto V Enhanced Half-Life 2 with RTX Indiana Jones And The Great Circle inZOI Monster Hunter Wilds Split Fiction The Last of Us Part II Remastered The Elder Scrolls IV: Oblivion Remastered Finally, Nvidia App 11.0.4 fixes the following bugs: Fixed an issue where DLSS-FG defaults to 2x irrespective of in-game setting when DLSS override model is set to "Latest” and Frame generation is set to “Use the 3D application setting". Fixed an issue where the driver download could not be completed. Fixed an issue where the recording bitrate setting was not saved. Fixed an issue where HDR video colors were not encoded properly for HEVC and AV1 playback. Fixed a bug where the in-game overlay was not accessible on the GeForce RTX 5070. Fixed an issue where a PC reboot would reset microphone boost to an incorrect value. Fixed an issue where Highlights summary window could not be disabled. Various stability fixes. You can download the Nvidia App from the official website. Full release notes are available here.
  • Recent Achievements

    • Conversation Starter
      lilyandrew11 earned a badge
      Conversation Starter
    • Contributor
      Ed B went up a rank
      Contributor
    • One Month Later
      moporcho earned a badge
      One Month Later
    • One Month Later
      Parotel earned a badge
      One Month Later
    • Reacting Well
      Cryptecks earned a badge
      Reacting Well
  • Popular Contributors

    1. 1
      +primortal
      188
    2. 2
      snowy owl
      135
    3. 3
      ATLien_0
      131
    4. 4
      Xenon
      119
    5. 5
      +FloatingFatMan
      101
  • Tell a friend

    Love Neowin? Tell a friend!