Automatically Accept Windows Remote Assistance Requests

There doesn’t seem to be a built-in way to do this on Windows Server 2008 R2. What we’re trying to achieve is a way to use Windows Remote Assistance to remotely control the session of a user, without that user needing to be present. This is a fairly rare scenario, but I’ve come across it for certain nasty bits of so-called “server” software that actually run as desktop applications (rather than services) and thus require a permanently logged on desktop that remote users can “hop on to” without the local user needing to press any buttons. Another use could be for a multimedia playback or wall-mounted display PC.

Obviously you could use a different piece of remote control software such as VNC but personally I prefer to stick to something that is built-in to Windows. OK, a confession, you do need to use 3rd party software, but not to provide the remote control or authentication. What I’m using for this solution is a very handy utility called AutoHotkey. It doesn’t need to be installed, you just copy the exe onto the system.

This solution allows specified users/groups to remote control an active desktop session of individually specified users on a Windows Server 2008 R2 machine. I’ve yet to test this method on 2008 or 2012. So to clarify, the users that are logged on to the server desktop have to be specified individually, you can’t make this work for any user who logs on (this is due to UAC). The remote users however can be specified by group membership. I’ve not tested any Windows Client OS, e.g. Vista, 7, 8. That said, this should work, even if it needs a slight modification.

The steps are as follows. These should be completed on the machine that you wish to remotely control.

Step 1 is to download AutoHotkey, create an AutoHotkey folder in Program Files(x86)and copy autohotkey.exe into it.

Step 2 is to put the following AutoHotkey script into a file called AcceptRemoteAssistance.ahk and put it into the same folder as AutoHotkey.exe

; Auto-Accept Remote Assistance requests for Windows Server 2008 R2
; rcmtech.co.uk, Sept. 2013
;
; keep this script running permanently
#Persistent
; set a timer to fire off the subroutine every 500msecs
SetTimer, CheckActiveWindow, 500

CheckActiveWindow:
; check to see if the active window is one of the Windows Remote Assistance ones that needs attention
if WinActive("Windows Remote Assistance","What are the privacy and security concerns","Being helped by"){
	; could be one of several different dialogue boxes that match the above criteria
	; only way to differentiate is by checking the size of the dialogue box
	WinGetActiveStats, Title, xDim, yDim, xPos, yPos
	if (yDim = 200){
		; or use xDim = 366
		; this is the initial "Would you like  to connect to you computer?"
		ControlGetText, ControlText, Button1, Windows Remote Assistance
		; verify that the expected button is the "Yes" button
		if (ControlText = "Yes"){
			; click the "Yes" button
			ControlClick, Yes, Windows Remote Assistance
		}
	}
	if (yDim = 181){
		; this is the subsequent "Would you like to allow  to share control of your desktop?"
		ControlGetText, ControlText, Button1, Windows Remote Assistance
		; verify that the expected button is the "yes" button
		if (ControlText = "Yes"){
			; tick the "Allow  to respond to User Account Control prompts" tickbox
			Click, 22, 117
			sleep 500
			; click the "Yes" button
			ControlClick, Yes, Windows Remote Assistance
		}
	}
}
return

Step 3 is to create a scheduled task to trigger the AutoHotkey script to run at logon for each local session user that needs to have Remote Assistance requests accepted automatically on behalf of. Note that the user(s) you are specifying here is/are NOT the people who will be initiating Remote Assistance requests to the computer (although they may be the same).

  1. Click Start, type Task Scheduler and open the Task Scheduler GUI
  2. Click on Task Scheduler Library
  3. Click Create Task…
  4. General tab:
    1. Name the task, something like Auto-Accept Remote Assistance for <user>
    2. Click the Change User or Group… button and set to the username for the desired user
    3. Tick the Run with highest privileges box
    4. Choose Configure for: whatever OS you’re currently running
  5. Triggers tab:
    1. Click New…
    2. Change Begin the task: to At log on
    3. Click Specific user: then the Change User… button and pick the same username as in 4B
    4. Click OK
  6. Actions tab:
    1. Click New…
    2. Action: should be Start a program
    3. Click Browse… and pick the AutoHotkey.exe executable file
    4. In the Add arguments (optional): box enter the full path to the AcceptRemoteAssistance.ahk file, including the usual double quotes if the path has spaces in it.
    5. Click OK
  7. Settings tab:
    1. Untick Stop the task if it runs longer than:
  8. Click OK

Step 4. Add the users who need to be able to remotely control the computer into the local group Offer Remote Assistance Helpers. This involves having to use Group Policy, even if only locally, you can run the local group policy editor by running gpedit.msc. The policy to set is found in Computer Configuration, Policies, Administrative Templates, System, Remote Assistance and is called Configure Offer Remote Assistance. You need to enable the policy, choose the option to allow helpers to remotely control the computer, and then add the users/groups via the Show… button. If the policy isn’t set, the Offer Remote Assistance Helpers group isn’t present, and if you add users/groups directly to that group they’ll be removed again on every group policy refresh interval (how annoying is that?).

Step 5. Disable the screensaver, and ensure that the On resume, display logon screen box is NOT ticked in the Screen Saver Settings dialogue.

Step 6. (optional) Use AutoLogon to get the computer to log on automatically if it reboots.

Step 7. Log off the computer and then back on again. You should find that the scheduled task has caused AutoHotkey to load and it should be running in the notification area. To verify that the script is running you can right-click the AutoHotkey icon and choose Edit This Script – the script should open in Notepad. If this is the first time the user has logged on to the computer the Scheduled Task seems not to work, possibly because the profile creation process takes longer than subsequent profile loads. In this case just log off and back on again a second time.

Now, from a computer logged on as one of the users you added to the remote computer’s Offer Remote Assistance Helpers group, you can start a Remote Assistance session to the computer. Do this either via the GUI:

  1. Click Start, type Assistance, click Windows Remote Assistance
  2. Click Help someone who has invited you
  3. Click the link Advanced connection option for help desk
  4. Fill out the computer name and click Next

Or via the command line:

msra /offerra <computername>

In both cases you may need to pick the user/session to connect to. Then the AutoHotkey script should kick in on the remote computer and click the Yes button. You’ll then need to click the Request control button in the Windows Remote Assistance GUI, at which point the script will kick in again and tick the Allow <name> to respond to User Account Control prompts box and then click the Yes button.

In case you’re worried, the AutoHotkey CPU usage seems to be so low as to be practically undetectable on my test VM (though admittedly it’s running on a host with E5-2690 CPUs).

To end the session the best way I’ve found is to just close the remote Windows Remote Assistance – Being helped by <name> utility. If you close your local Windows Remote Assistance – Helping <name> then you end up with an “orphaned” (albeit inactive) WRA process left running on the remote computer.

If the AutoHotkey script doesn’t work it may be that the dialogue boxes are not opening with the same dimensions as on my systems. AutoHotkey comes with a utility called Window Spy (AU3_Spy.exe) which will tell you the active window width and/or height, compare these values to the ones in my script and modify as necessary. These are the only things I’ve found that differentiate the various different dialogue boxes titled Windows Remote Assistance. I know it’s a bit nasty, leave me a comment if you find a nicer way to do it!

Update: Have now created a new version of the script for Windows Server 2003, see below. Additionally, due to the lack of UAC on this OS, you can just create a shortcut to run the AutoHotkey script and put it in the All Users Start Menu Startup folder, no need for the scheduled task. Thus, this method will work for any logged on user on this OS.

; Auto-Accept Remote Assistance requests for Windows Server 2003
; rcmtech.co.uk, Sept. 2013
;
; keep this script running permanently
#Persistent
; set a timer to fire off the subroutine every 500msecs
SetTimer, CheckActiveWindow, 500

CheckActiveWindow:
; check to see if the active window is one of the Windows Remote Assistance ones that needs attention
if WinActive("Remote Assistance","","Webpage Dialog",""){
	; could be one of several different dialogue boxes that match the above criteria
	; only way to differentiate is by checking the size of the dialogue box
	WinGetActiveStats, Title, xDim, yDim, xPos, yPos
	if (yDim = 178){
		; or use xDim = 405
		; this is the initial "Would you like  to connect to you computer?"
		; click the "Yes" button
		Click, 294, 147
	}
}
if WinActive("Remote Assistance -- Webpage Dialog"){
	; this should be the dialogue that opens when the helper clicks "Request Control"
	if (yDim = 340){
		; this is the subsequent "Would you like to allow  to share control of your desktop?"
		; click the "Yes" button
		Click, 297, 165
	}
}
return

If you modify the script for any other OSs please let me know.

This entry was posted in Windows and tagged , , , , , , , , , , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s