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

    • Ah yes, nothing says 'user-friendly' like 500 distros and 0 standards.
    • If this doesn't become the year of the Linux desktop, then it will never come. They already wasted the Windows Vista fiasco, the Windows 8 fiasco, let's see what will happen now.
    • Linux is the way to go, so many distributers with great offerings, no more bloatware with Windows 11, the Linux operating system boots much more quickly with much lower CPU requirements, why wouldn't you if you only need a great browsers to access online services.
    • Master PDF Editor 5.9.90 by Razvan Serea Master PDF Editor is straightforward, easy to use application for working with PDF documents equipped with powerful multi-purpose functionality. With Master PDF Editor you can easily view, create and modify PDF documents. The application enables you to merge several files into one, split a source document into multiple documents, and also to comment, sign and encrypt PDF files. Master PDF Editor – Features at a glance: Edit PDF text, images and pages with full editing features. Create new PDF or edit existing ones. Add and/or edit bookmarks in PDF files. Encrypt and/or protect PDF files using 128 bit encryption. Convert XPS files into PDF. Add PDF controls (like buttons, checkboxes, lists, etc.) into your PDFs. Import/export PDF pages into common graphical formats including BMP, JPG, PNG, and TIFF. Split and merge PDF files. JavaScript support. Dynamic XFA form support. Validation Forms and Calculate Values. Fast and simple PDF forms fill out. Signing PDF documents with digital signature, signatures creation and validation. Changing font attributes (size, family, color etc). Master PDF Editor 5.9.90 changelog: Added support for page alignment options. Added the function to save search history. Added support for Z-reordering multiple objects simultaneously. Fractional scale values are supported during printing. General improvements and fixes for file saving. Fixed issues related to PDF page display. Fixed problems related to navigation between pages. Improved compatibility with XFA-based PDF documents. Bug fix for text object editing. Fixed bugs related to page cropping. Enhanced detection of conflicting keyboard shortcuts. Resolved printing issues. Fixed a bug related to increase in the file size when scanning. Fixed PDF preview rendering in Microsoft Outlook. Resolved an issue with opening Certificate Manager on macOS. Download: Master PDF Editor 64-bit | Master PDF Editor 32-bit ~60.0 MB (Shareware) Download: Master PDF Editor for Linux | 66.8 MB Download: Master PDF Editor for macOS | 59.8 MB View: Master PDF Editor Home Page | Release History | Screenshot Get alerted to all of our Software updates on Twitter at @NeowinSoftware
    • NTLite 2025.06.10456 by Razvan Serea NTLite is a Windows configuration tool that allows you to modify your existing Windows install or an image yet to be deployed, remove Windows components, configure and integrate, speed up the Windows deployment process. Reduce Windows footprint on your RAM and storage drive memory. Remove components of your choice, guarded by compatibility safety mechanisms, which speed up finding that sweet spot. Windows Unattended feature support, providing many commonly used options on a single page for easy setup. Easily integrate a single or multiple drivers, update or language packages. Package integration features smart sorting, enabling you to seamlessly add packages for integration and the tool will apply them in the appropriate order, keeping hotfix compatibility in check. One of the important new features of NTLite (compared to its predecessors) is the ability to modify an already installed the operating system, by removing unnecessary components. Supports Windows 11, 10, 8.1 and 7, x86 and x64, live and image. Server editions of the same versions, excluding support for component removals and feature configuration. ARM64 image support in the alpha stage. Does not support Checked/Debug, Embedded, IoT editions, nor Vista or XP. NTLite 2025.06.10456 changelog: New Image: Windows 11 24H2 Preview build 26120 support Components: ‘Microsoft Platform Thermal Framework (MPTF)’ Components: ‘Inter-Integrated Circuit (I2C)’ Components: ‘Windows Hotpatching’ Settings: ‘Share any window from my taskbar’ Upgrade Image: Faster removal of editions if only one kept for a given image Components: ‘Windows Feature Experience Pack – SXS’ is a merger of new 24H2 components: Taskbar, Filons, Voiess, Speion, Livtop and InpApp Features: Win11 24H2 image shows a few more Features on Demand, including .NET 3.5 UI-Translation: Thanks for Chinese Traditional (Matt), French (tistou77), Hungarian (John), Italian (clarensio), Russian (RDS), Turkish (Salih DURDU) Fix Components: ‘Internet printing’ is needed for Host Refresh if Printing kept (investigating, cannot even just disable it) Settings: Wallpaper Style value fixes Download: NTLite 64-bit | 21.2 MB (Free, paid upgrade available) Download: NTLite 32-bit | 18.8 MB Link: NTLite Home Page | NTLite Features | Screenshot Get alerted to all of our Software updates on Twitter at @NeowinSoftware
  • Recent Achievements

    • One Year In
      fred8615 earned a badge
      One Year In
    • Week One Done
      Jim Dugan earned a badge
      Week One Done
    • Week One Done
      Adam Todd earned a badge
      Week One Done
    • Contributor
      Ed B went up a rank
      Contributor
    • One Month Later
      moporcho earned a badge
      One Month Later
  • Popular Contributors

    1. 1
      +primortal
      214
    2. 2
      snowy owl
      156
    3. 3
      ATLien_0
      134
    4. 4
      Xenon
      123
    5. 5
      +FloatingFatMan
      114
  • Tell a friend

    Love Neowin? Tell a friend!