RA: Pass Workstation and Username Parameters to Offer Remote Assistance

Filed under: Quick Code, Security — Written by Chrissy on Wednesday, December 13th, 2006 @ 12:21 pm

For those of you who successfully use the shortcut for Offer Remote Assistance (ORA), you've probably wanted to automate it just a little more with parameters at some point or another. You may have even come across EdmSaleBoy's Usenet Post titled "Programatically Offer Remote Assistance." I did a few times but it didn't do exactly what I wanted to. Though I appreciated EdmSaleBoy's code extraction skills, I didn't find the solution of overwriting UnsolicitedCUI.htm to be very elegant so I spent some hours looking into alternatives.

ORA is a bit of a programming pain because it requires client-side Javascript and it's picky about what it will and will not let you do. I wanted to find a way to call ORA from a webpage and wondered how I would pass some variables to the script. The command line was not cooperating with me so I thought that perhaps I could hack together something with javascript and Microsoft.XMLHTTP but ORA denied me access. After some hackery, I discovered the joys of objSAFClassFactory.ExtraArgument.

Using objSAFClassFactory.ExtraArgument, I was able to dynamically pass the workstation name and username (note: the username MUST be in the domain\username format or it won't work.) So now I present to you the following code, which you can save as cmdOfferRemoteAdmin.htm under the directory %windir%\pchealth\helpctr\System\.

cmdOfferRemoteAdmin.htm

<html XMLNS:helpcenter>
<head>
<!--
Copyright (c) 2000 Microsoft Corporation
-->
<helpcenter:context id=idCtx />
<title>Remote Assistance</title>
<!-- The SAF class factory object -->
<object classid=CLSID:FC7D9E02-3F9E-11d3-93C0-00C04F72DAF7 height=0 id=objSAFClassFactory width=0></object>
<script LANGUAGE="Javascript">
function onContinue()
{
var g_szWorkstation = null;
var g_szUsername = null;
var c_WorkstationTag = "WORKSTATION=";
var c_UsernameTag = "&USERNAME=";
 
var szArgs = objSAFClassFactory.ExtraArgument;
 
var i = szArgs.indexOf(c_WorkstationTag);
var j = szArgs.indexOf(c_UsernameTag);
g_szWorkstation = szArgs.slice(i+c_WorkstationTag.length, j);
g_szUsername = szArgs.slice(j+c_UsernameTag.length);
 
var i = g_szUsername.indexOf("");
g_szDomainName = g_szUsername.slice(0, i);
g_szUserName = g_szUsername.slice(i+1);
g_szSessionId = -1;
 
g_oSAFRemoteDesktopConnection = objSAFClassFactory.CreateObject_RemoteDesktopConnection();
g_oSAFRemoteConnectionData = g_oSAFRemoteDesktopConnection.ConnectRemoteDesktop(g_szWorkstation);
 
objInc = objSAFClassFactory.CreateObject_Incident();
objInc.RCTicketEncrypted = false;
objInc.RcTicket = g_oSAFRemoteConnectionData.ConnectionParms( g_szWorkstation, g_szUserName, g_szDomainName, -1, "");
var objDict = objInc.Misc;
var d = new Date();
objDict.add("DtStart", Math.round(Date.parse(d)/1000));
objDict.add("DtLength", "60");
objDict.add("Status", "Active");
objDict.add("URA", 1);
objFSO = new ActiveXObject("Scripting.FileSystemObject");
tempDir = objFSO.GetSpecialFolder( 2 );
szIncidentFile = tempDir + "\UnsolicitedRA" + objFSO.GetTempName();
objInc.GetXML(szIncidentFile);
var oShell = new ActiveXObject("WScript.Shell");
var szRAURL = 'C:\WINDOWS\pchealth\helpctr\binaries\helpctr.exe -Mode "hcp://system/Remote Assistance/raura.xml" -url "hcp://system/Remote Assistance/Interaction/Client/RcToolscreen1.htm"' + ' -ExtraArgument "IncidentFile=' + szIncidentFile + '"';
oShell.Run( szRAURL, 1, true );
objFSO.DeleteFile( szIncidentFile );
objSAFClassFactory.close();
return;
}
</script>
</head>
<body onload="onContinue();">
</body>
</html>

Once you saved the file in the proper location, you can call it by going to

%windir%\PCHEALTH\HELPCTR\Binaries\HelpCtr.exe -url hcp://system/cmdOfferRemoteAdmin.htm -ExtraArgument "WORKSTATION=winxpsp2&USERNAME=testlab\chrissy"

The downside to this code is that there's little to no error handling. If just a blank "Windows Help" page appears, you've done something wrong. Make sure the computer you are attempting to connect to is pingable and that the username is in the correct format (domain\user). Also, make sure you can get the regular Offer Remote Assistance to work before calling this more advanced technique. If you are having trouble with ORA, this posting may provide some help.

9 Comments   -
  • Comment by Zac | December 30, 2006 @ 7:29 pm

    The way to take away the Accept dialog is the following:

    In the c:\windows\pchealth\HelpCtr\System\Remote Assistance\helpeeaccept.htm you need to find these lines:

    btnAccept.disabled = false;
    btnDecline.disabled = false;
    btnDecline.focus();

    to this

    btnAccept.disabled = false;
    btnDecline.disabled = false;
    btnDecline.focus();
    DoAccept();

    I found this courtesy of the following forum:

    http://www.anetforums.com/posts.aspx?ThreadIndex=3115

    The thread also shows how to disable the Take Control prompt but I haven't tried that yet.

  • Comment by Zac | December 30, 2006 @ 7:36 pm

    OK, I followed the instructions on the thread and also was able to disable the Accept dialog for Take Control.

    Per the thread I had to do the following:

    change the file %WINDIR\pchealth\HelpCtr\System\Remote Assistance\Interaction\Server\TakeControlMsgs.htm

    find these lines:
    idExpert1.innerText = vArgs[0];
    idExpert2.innerText = vArgs[0];
    idExpert3.innerText = vArgs[0];

    Then add the following line below, but before the close bracket.
    // Added to allow take remote control of PC
    onClickHandler(0)

    I tested this and it works in a non-domain environment on a LAN between 2 XP Pro 32 bit machines.

  • Comment by MarkyMark | January 19, 2007 @ 10:14 am

    ok...This looks like a handy tool but can the process be reversed? I want a short cut on each of my users desktops asking for remote assistance. This would then produce a pop up your email on my end. Is this possable? They all sit behind NAT on networks all over the contry so the tool above doesn't really help me due to the NAT on there end.

    M

  • Comment by Steve | February 23, 2007 @ 10:04 pm

    Change the code in C:\WINDOWS\PCHEALTH\HELPCTR\Vendors\CN=Microsoft Corporation,L=Redmond,S=Washington,C=US\Remote Assistance\Escalation\Unsolicited\unsolicedrcui.htm to include a variable grabber and enter the variable as the default value in the idComputerName box... Seems logical anyway...

  • Comment by Dave | March 20, 2007 @ 12:46 am

    I'm sorry, I'm not good with HTML, can you give me some idea where I can get started in that file?

  • Comment by edward | March 22, 2007 @ 12:32 am

    hi,
    i edited the htm files and be able to remote to client computer without user clicking OK, but if client have a computer locked then you can't do anything with it. is there anyway we can hit the control +alt +delete to log in? thanks

  • Comment by chris | May 4, 2007 @ 7:35 am

    this looks very promising but i'd like to simplify it a bit. i dont quite need the automation of passing the username (although that worked successfully). can i chop out the code requiring the username and just pass the computername? The goal is to open help center with the computer field populated, and let the choosing of the user session be a manual process from there forward.

    thanks for any assistance, nice effort too, not much posted on how to do this.

    chris

  • Comment by Ron | May 25, 2007 @ 7:55 am

    That is a very nice example of how to interact with Remote Assistance. I incorporated something similiar in a program I wrote. Passing the machine name using oSAFClassFactory.ExtraArgument to a slightly modified version of unsolicited.htm allows it to still poll the remote machine for active users. If anyone is interested Remote Assistance Helper can be dowloaded at www.digitaltaproom.com. It's free by the way.

  • Comment by Kevin | November 6, 2007 @ 4:57 pm

    This is exactly what I've been looking for!!! But I'm getting the dreaded Blank Help page... is there any way to trace the code to figure out where it is going wrong?

    I am able to "Offer remote assistance" when I type the fields in manually, but I want that piece to be automated via the parameter passing... If I could get this to work I'd be a happy guy!

Leave your comment