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

    • I’m new to the Neowin forum and just wanted to introduce myself. I’ve always had an interest in tech — especially Windows, software updates, and gadgets. I’ve been reading posts here for a while, and it seemed like a good time to finally join in and be part of the conversation. Outside of tech, I enjoy music, movies, and keeping up with the latest news in the digital world. I’m hoping to learn from others, share a few tips of my own, and have some good discussions.
    • Hey! What a difference it makes to upgrade from an old WiFi 5 router to a new one. The Asus BE88U and BE92U are both very top picks. Asus gives you more control and better firmware support than most. Netgear’s new stuff is decent, but locked down. If you need more than 4 wired ports, I’d suggest a separate 2.5G or 10G switch. It makes life easier. Synology’s UI is clean too, but they don’t have a WiFi 7 router yet. If the price isn’t a big deal, go with Asus and pair it with a switch. Let us know what you think!  
    • Honestly, I think the long-term play here is for Microsoft to ditch the idea of a traditional console entirely and just turn Xbox into a full-on operating system. They (or anyone!) could release hardware like a Mac Mini or a typical console with built-in GPU and RAM, but instead of being locked into a console ecosystem, they run the Xbox OS. It makes total sense because it pushes Game Pass, Windows, and all their other software. The handheld angle is really interesting too. You’d basically have a portable PC. Hook up a keyboard and mouse, and suddenly you can edit videos or get some real work done while on the go. Something like a prebuilt Xbox PC would be more than just a gaming box. It could be a decent little PC that people might actually upgrade with each generation. And since it’s running a PC-based OS, you’d get all the usual perks like mod support, cheaper games across different stores, and no extra charges just to plug in a webcam or other standard accessories. Plus, if they let you install the OS on your own rig, then you’ve got full upgradability too. Best bit also being Microsoft wont even need to build them anyone can and when they do Microsoft just wins. The competition is kind of stuffed. Those maybe relying on SteamOS might be ok but will still have software support issues and no Game Pass. Sony and Nintendo can’t really offer the same kind of flexibility at all not sure how they will live on. They’d struggle to match something that works as a desktop OS, console, handheld, streaming box, and media hub, all with your game library ready to go, never needing to rebuy games. Console exclusives are the only way they can live I think, but if they ever get blocked by antitrust rulings down the line, it’s game over. I'm waiting to see the bloat that's still left on these and if they let you install on a regular old PC. Fingers crossed this could be the lightweight OS we have been asking for.
    • I take my Apple Watch off at night and put it on the charger when I go to bed. Then I wake up the next morning I put it back on.
  • Recent Achievements

    • Conversation Starter
      NeoToad777 earned a badge
      Conversation Starter
    • Week One Done
      VicByrd earned a badge
      Week One Done
    • Reacting Well
      NeoToad777 earned a badge
      Reacting Well
    • Reacting Well
      eric79XXL earned a badge
      Reacting Well
    • First Post
      brynmot earned a badge
      First Post
  • Popular Contributors

    1. 1
      +primortal
      480
    2. 2
      +FloatingFatMan
      277
    3. 3
      ATLien_0
      243
    4. 4
      snowy owl
      209
    5. 5
      Edouard
      187
  • Tell a friend

    Love Neowin? Tell a friend!