Jump to content

Detect how computer was waken up?


VAN0
 Share

Recommended Posts

Hello.

I'm looking for a way detect if computer was woken up via Wake On Lan.

Normally I'd use

powercfg /lastwake

but unfortunately it show system specific result, which could be different on other systems:

C:\Windows\system32>powercfg /lastwake
Wake History Count - 1
Wake History [0]
  Wake Source Count - 1
  Wake Source [0]
    Type: Device
    Instance Path: PCI\VEN_8086&DEV_15A1&SUBSYS_15A11849&REV_00\3&11583659&0&C8
    Friendly Name: Intel(R) Ethernet Connection (2) I218-V
    Description: Intel(R) Ethernet Connection (2) I218-V
    Manufacturer: Intel Corporation

 

Any suggestions?

Thank you.

Link to comment
Share on other sites

Just curious, but why do you want to know this?

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

I'm using SyncMe app on my phone, for backup files from phone to computer. That app uses WoL to wake the computer and it could take hours or minutes to finish backup.

So I created a script that monitor a folder on the computer for a specific file (SyncMe set to upload the file last), once file found it would put computer back to sleep. It works, but I'd like it to activate sleep mode only if computer was woken up via WoL.

Edited by VAN0
Link to comment
Share on other sites

I think for now I'm going for different approach - check for user activity between wake and finish of the sync.

 

@AdamUL: not only it's was useless response (I've already covered this method in my original post), but also incorrect all together: powercfg doesn't accept switches that start with a "-"

Edited by VAN0
Link to comment
Share on other sites

Just rule out the other options with a series of "If Not stringinstr($s , "Power Button) AND If Not ..."?

And fwiw,  powercfg accepts / - or no switch at all for parameters.

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Link to comment
Share on other sites

  • Developers

Wrote this one a long time ago, maybe that is something that helps?:

 

Edited by Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Just rule out the other options with a series of "If Not stringinstr($s , "Power Button) AND If Not ..."?

And fwiw,  powercfg accepts / - or no switch at all for parameters.

Here is the result when used mouse to wake up:

C:\Windows\system32>powercfg /lastwake
Wake History Count - 1
Wake History [0]
  Wake Source Count - 1
  Wake Source [0]
    Type: Device
    Instance Path: PCI\VEN_8086&DEV_8CB1&SUBSYS_8CB11849&REV_00\3&11583659&0&A0
    Friendly Name: Intel(R) USB 3.0 eXtensible Host Controller - 1.0 (Microsoft)
    Description: USB xHCI Compliant Host Controller
    Manufacturer: Generic USB xHCI Host Controller
Again it's system specific.
Strange, it never worked for me with "-" switch:
C:\Users\Storage User>powercfg -lastwake
Invalid Parameters -- try "/?" for help

didn't know about without / or - though, nice.

 

You can also use the EventLog UDF included with AutoIt, and search the System logs for Event ID 1.  

http://superuser.com/questions/485131/how-can-i-tell-if-my-computer-went-to-sleep

Unfortunately it shows pretty much the same as powercfg /lastwake, just cleaned up a little.

 

Wrote this one a long time ago, maybe that is something that helps?:

Thank you, that definitely very useful for my script.

Link to comment
Share on other sites

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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...