Sysinternals Homepage
Forum Home Forum Home > Windows Discussions > Troubleshooting
  New Posts New Posts RSS Feed: Remote Desktop After Wol(Wake on Lan)
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

Remote Desktop After Wol(Wake on Lan)

 Post Reply Post Reply Page  <12345>
Author
Message Reverse Sort Order
Innocence View Drop Down
Newbie
Newbie


Joined: 21 July 2009
Online Status: Offline
Posts: 4
Post Options Post Options   Quote Innocence Quote  Post ReplyReply Direct Link To This Post Topic: Remote Desktop After Wol(Wake on Lan)
    Posted: 22 July 2009 at 7:41am

Ok, so you ARE my hero! :D

After installing StayAwake, for the first time in weeks my server didn't automatically return to standby after waking up at midnight!!! Clap
 
Incidentally, the problem with the server returning to standby *doesn't* happen when it's awakened by WOL - it only happens when I use Windows Task Scheduler to automatically wake up the machine (at midnight).
 
The server is running a looping batch script (as a Windows Service) which checks for activity on certain network ports. If there's no activity it starts a 5 minute countdown (which naturally is reset if activity is detected). After 5 minutes without activity the script sends the server into Standby mode. The server wakes up if it receives a WOL packet and the script resumes. At midnight, Windows Task Scheduler wakes up the machine and the script resumes as normal. When the script discovers it's after midnight it performs various housekeeping tasks, like staring the backup utility, updating EPG etc. Once all tasks have finished it returns to the standard loop, and if no activity is detected during the 5 minute countdown it performs a full shutdown/power off. At 6 in the morning, the PC BIOS powers on the computer and the whole thing starts again :)
Back to Top
Innocence View Drop Down
Newbie
Newbie


Joined: 21 July 2009
Online Status: Offline
Posts: 4
Post Options Post Options   Quote Innocence Quote  Post ReplyReply Direct Link To This Post Posted: 21 July 2009 at 9:39am
Originally posted by Shaker

I think, I did it!
I've got the same issue with my MediaPC, stuck in the basement on Standby and only waking up when a device needs it or it needs to do nightly housekeeping (backups etc.). This infamous System Idle Timer problem is the last thing I needed a fix for, so I'll test it tonight.
 
If it works you're my hero :)
Back to Top
mguinness View Drop Down
Newbie
Newbie


Joined: 19 May 2009
Online Status: Offline
Posts: 9
Post Options Post Options   Quote mguinness Quote  Post ReplyReply Direct Link To This Post Posted: 06 July 2009 at 9:45pm
Nice job Shaker.  I haven't used the code myself as I've not had the timeout issue, but hopefully this code will work for muotoko too.  Thanks for sharing.
Back to Top
Shaker View Drop Down
Newbie
Newbie
Avatar

Joined: 10 June 2009
Location: Roesrath - DE
Online Status: Offline
Posts: 10
Post Options Post Options   Quote Shaker Quote  Post ReplyReply Direct Link To This Post Posted: 11 June 2009 at 1:27am
I think, I did it!
Usually my PC returned to sleep after 9 minutes ! (Somehow not 120 seconds unattended idle timer).
With the service installed and running, it stays on beyond these 9 minutes even after WOL !

binary file: http://freeware.satria.de/StayAwake/StayAwake.exe
source code: http://freeware.satria.de/StayAwake/StayAwake.cs

Corrected EventLog-handling.
Added more log-messages.
Added the API-call to keep system awake (not only display refresh as before)
Added a 60-seconds "keep-alive" timer because the API-call didn't do it :)

Build is up to you, if you like.
Installation of the exe works as described before:
...\InstallUtil StayAwake.exe

Logs into the Application EventLog. For more logging add the parameter to the service-image (in Windows REgistry): /debug

Enjoy WOL and remote desktop ;)
Back to Top
Shaker View Drop Down
Newbie
Newbie
Avatar

Joined: 10 June 2009
Location: Roesrath - DE
Online Status: Offline
Posts: 10
Post Options Post Options   Quote Shaker Quote  Post ReplyReply Direct Link To This Post Posted: 10 June 2009 at 10:05am
Originally posted by muotoko

When I resume with wol, it wakes and the display wakes up also so that works, but it goes right back to sleep in a couple of minutes.


Hi! After looking around everywhere ;) on the web, this seems to be the most promising thread dealing with this problem. I have exactly the same demand !

I am a programmer myself and I think I understand the SetThreadExecutionState() API function. In the nice .cs file here the only intention currently is to turn on the display upon wake-up, not to keep the system alive.

Since I am very eager to solve this problem it is very likely that I modify the code and post it back here after successful testing later today. Like midnight or so... things to do until then... I will try to re-code the service, so that it keeps the system awake (not necessarily the display), and maybe it will also react to user inputs (keyboard) and then turn off its actions to "get back to normal", letting system idle timer to its job ;)
Back to Top
mguinness View Drop Down
Newbie
Newbie


Joined: 19 May 2009
Online Status: Offline
Posts: 9
Post Options Post Options   Quote mguinness Quote  Post ReplyReply Direct Link To This Post Posted: 02 June 2009 at 4:18am
I understand your frustration, the power saving feature seems to either work well or not at all.  The display issue that I resolved with a workaround is software related.  The issue you have seems to be hardware related, probably at the BIOS level.
 
The unattended idle timer settings for Vista can be defined by changing the registry:
 
I found an article related to XP, but I don't think there is a associated idle timeout setting:
 
If you want to try to broadcast PBT_APMRESUMESUSPEND you can using SendMessage (http://www.pinvoke.net/default.aspx/user32.SendMessage) with WM_POWERBROADCAST as the message.
 
Also, maybe try the following freeware application that has a feature of "prevent the system from suspending if a TCP connection on specified ports is active".  You would need to define TCP port 3389 for remote desktop:


Edited by mguinness - 02 June 2009 at 4:23am
Back to Top
muotoko View Drop Down
Newbie
Newbie


Joined: 24 May 2009
Online Status: Offline
Posts: 6
Post Options Post Options   Quote muotoko Quote  Post ReplyReply Direct Link To This Post Posted: 02 June 2009 at 1:14am
I am using a magic packet to wake it up.  I have access to the pc, it's just in another room.  When I use the magic packet to wake it up it goes right back to sleep in a couple of minutes.  I even tried hibernate which also wakes up the display and a couple of minutes after goes back to hibernate.

From what I've been reading this was intentional from Microsoft, they want it to use the unattended idle timer unless the pc is physically interacted with.  They even added an option to change the amount of time the unattended idle timer has before going back to standby in Vista SP1, unfortunately I don't think there is an option in XP which is what I am using. 

The only thing is other people like you say it doesn't happen to them.  I've also read that people who had the problem replaced their motherboard and it doesn't happen anymore and also the opposite where they didn't have the problem and replaced their motherboard and it happens now.  Of all the reports though I haven't read one where they were able to fix the problem without replacing the motherboard.  Which is why I was hoping there was a way to force windows to broadcast PBT_APMRESUMESUSPEND when it resumes from standby, which is what is broadcasted when the pc is physically intereacted with after resume from suspend.  I've even tried using scripts to run simulated keypresses and mouse movements upon wake up of the pc, but it doesn't consider them as the user doing it.  I guess there isn't anything I can do about it.  I've even updated my bios, and nic drivers with no change.  Guess I'll just have to leave it on all the time.

Thank you so much for all your help, mguinness.  I truly appreciate it.
Back to Top
mguinness View Drop Down
Newbie
Newbie


Joined: 19 May 2009
Online Status: Offline
Posts: 9
Post Options Post Options   Quote mguinness Quote  Post ReplyReply Direct Link To This Post Posted: 01 June 2009 at 7:50pm

I don't have that problem myself and I too have the Broadcom NetXtreme adapter.  On the adapter property page in XP are you using the Magic Packet or Wake Up Frame option?  If the latter, are you using a Magic Packet to wake up the PC?  Are you able to watch the PC in question to see if it has indeed gone back to sleep, or are you in a remote location when trying this? 

Logically, if it's network traffic causing wake up, it makes sense to go back to sleep afterwards (think file share).  However if it's a network adminstrator sending a magic packet it makes sense to stay awake (think virus scan).  Of course, MS in their infinite wisdom may have implemented this differently but without having access to their code it's hard to say.
Back to Top
muotoko View Drop Down
Newbie
Newbie


Joined: 24 May 2009
Online Status: Offline
Posts: 6
Post Options Post Options   Quote muotoko Quote  Post ReplyReply Direct Link To This Post Posted: 31 May 2009 at 9:40am
Nope, that didn't help.  I think that is just to prevent anything other than a magic packet from waking up the pc.
Back to Top
mguinness View Drop Down
Newbie
Newbie


Joined: 19 May 2009
Online Status: Offline
Posts: 9
Post Options Post Options   Quote mguinness Quote  Post ReplyReply Direct Link To This Post Posted: 30 May 2009 at 8:16pm

Read this http://support.microsoft.com/kb/810719 to see if it helps.



Edited by mguinness - 31 May 2009 at 2:27am
Back to Top
 Post Reply Post Reply Page  <12345>

Forum Jump Forum Permissions View Drop Down