Windows 7 come out of sleep when I open remote desktop

69,693

Solution 1

You'll need to send a magic packet (For Wake ON LAN) through your router. Difficult because router's don't forward these by default, but there are workarounds as found here:

In order to wake up a computer from the Internet you need a Broadband connection with a Router connected to the Modem that keeps your connection alive (you need a Router even if you have Static IP).

Waking Up the computer from remote is done by sending the magic packet through the Internet using your Internet IP address, and the MAC number of the computer that you intend to Wake Up.

If you do not know your IP address:

Link to: How I find my Computer/Server Internet address from remote location.

You have to prepare the system for Wake Up Over the Internet.

Open a Port thought the Router, and the Software Firewall (use high port number so it will not conflict with any other port, 5850 is a good example).

Assign the port to the internal IP of the computer that you want to WOL (you can use the port only for one computer).

Get this Utility it let you define a port for WOL.

Link to: Wake on LAN for Windows Graphical User Interface (WOL GUI)

Take with you a copy of the WOL GUI, and write down the MAC number. In the remote location start WOL GUI and type in your MAC number, Type in the Internet address (Internet IP) type in the port number that you left Open. Click on Wake me Up and it should work.

The utility:

alt text

The magic packet GUI utility is freeware.


You can also use a hotkey to wake it along with the command line version of Wake On LAN:

The Syntax:

C:\path\to\wolcmd.exe [Mac address] [IP address] [Subnet mask] [port number]

Making things easier:

!w::Run, C:\wolcmd.exe 009027a324fe 195.188.159.20 255.255.255.0 8900
  • Alt + w will wake the remote computer

modify the script accordingly so the path points to the wolcmd.exe executable and the MAC, IP, and subnet are correct.

Solution 2

Improving on John Sibly's answer... if in windows you can avoid C# code by using the "timeout" cmd as below.

ECHO OFF
CLS
WolCmd.exe MAC_OF_NIC IP_ADDR MASK 7
timeout 10
ECHO Starting remote desktop connection
start mstsc.exe mycomputer.rdp

See this answer on StackOverflow for more option regarding the sleep section of the .cmd file: https://stackoverflow.com/questions/4317020/windows-batch-sleep

Solution 3

Using the information from the other answers, I ended up creating a folder containing the following files:

connect.bat
mycomputer.rdp (remote desktop connection file)
sleep.exe (a little program to wait a specified number of milliseconds)
wolcmd.exe

So running connect.bat, wakes up my computer, waits 10 seconds, and then opens a remote desktop connection to it.

connect.bat contains the following:

ECHO OFF
CLS
WolCmd.exe 0011AA22BB33 10.1.255.255 255.255.0.0 7
ECHO Sleeping...
Sleep.exe 10000
ECHO Starting remote desktop connection
start mstsc.exe mycomputer.rdp

You can generate sleep.exe by saving the source below as sleep.cs, and compliling it using the C# compiler that comes with the .NET framework:

csc /out:sleep.exe c:\sleep.cs

Source for sleep.cs

using System;
using System.Threading;

namespace Sleep
{
    class Program
    {
        static void Main(string[] args)
        {
            if (args.Length == 1)
            {
                int period = 0;
                Int32.TryParse(args[0], out period);
                Console.WriteLine("Sleeping for {0} ms", period);
                Thread.Sleep(period);
            }
        }
    }
}

Solution 4

Remote Desktop does not have any built-in remote wake-up capability.

You may be able to configure your network card to wake up on any packet. However, this will probably not work like you intended - as it won't discriminate between your remote desktop connection attempt and someone just scanning your network or a latent packet from a service you were using.

For now, you will probably have to settle with a two-step process: 1) wake the computer with one application, 2) Connect via remote desktop.

Solution 5

You need a network adapter that support ARP offload and TCP SYN wake pattern as stated in http://technet.microsoft.com/en-us/library/ee617165%28v=ws.10%29.aspx

If those features are supported and enabled, then whindos won't warn you about sleep/hibernate policy when you turn on remote desktop.

Share:
69,693

Related videos on Youtube

John Sibly
Author by

John Sibly

Updated on September 17, 2022

Comments

  • John Sibly
    John Sibly almost 2 years

    Is there any way to have a Windows 7 machine come out of sleep automatically when I try and connect to it with Remote Desktop?

    The power saving option of the machine I want to connect to (enforced by group policy I believe) is to sleep after 30 minutes, which means I have to either physically walk over to press a key, or fire up a separate Wake-on-LAN tool to get it out of sleep mode.

    I would be nice if the Remote Desktop Connection client sent the Wake-on-LAN packet automatically - is this possible?

    • Admin
      Admin over 12 years
      Don't newer motherboards have this feature?
    • John Sibly
      John Sibly over 10 years
      @DalinSeivewright Yes they do-my newest dev machine does this automatically now :)
  • John Sibly
    John Sibly over 14 years
    Hi John - yes this is the tool I currently have to use if I want to get this computer out of sleep. I was wondering if it was possible for Remote Desktop to do it automatically?
  • John T
    John T over 14 years
    Natively i dont know of a way to do it automatically, and If I use AutoHotkey to wake it automatically when you open remote desktop, opening RDC for a different reason will still wake your home computer which you do not want, so I edited my answer to elaborate on how to set a hotkey to wake your remote computer.
  • Guy Thomas
    Guy Thomas over 14 years
    John T's answer is brilliant. All I can add is that I created a short cut on my desktop with: wol -i 192.168.1.61 -p 00:24:8C:1F:90:23 wol 00:24:8C:1F:90:23 (Can't remember why I added two similar commands) Then I assign the shortcut a keyboard combo e.g Ctrl +shift +j Works fine for a desktop machine. But struggling with my laptop's nic.
  • John Sibly
    John Sibly over 14 years
    Thanks for all the feedback. The command line version looks very promising - I think the solution (for me at least) is to create a batch file to: call the command line tool, wait for 5 seconds or so, and launch "mstsc.exe mycomputer.rdp"
  • John Sibly
    John Sibly about 12 years
    Useful command - I'll have to remember that for future batch files :)
  • John Sibly
    John Sibly over 10 years
    I've notice that this works on my newest dev machine-I guess this is the reason why.