7

I have an app that I'm trying to run on an intranet. On my machine it worked great (famous last words) but when I put it up to the server, it didn't work. As soon as I saw the "the system cannot find the specified file" error, I figured it had to be something with trying to run a program that's on a client machine.

Yes, it would be a security nightmare if any app in a browser could run an executable on a client machine. Is this any different for intranet? The few computers it would run on all have the same version of IE and .NET that it will run on, and they all have the required .exe to run.

Here's an overview of the project:

  • An employee and a participant walk into a room containing a computer.
  • The employee opens my web app and looks up the person's ID (this part works)
  • Clicking on "record" should perform a hidden launch of an already-installed program, which begins recording.
  • When finished, the employee clicks finish (or the app times out) and the file is saved.
  • File gets uploaded to server.
  • The employees lack technical experience, so my objective is to pretty much have a website for them to go to where there is little more than a box to get the participant ID and two giant "RECORD" and "STOP" buttons

Can anyone help me out on how to do this (or at least let me know it's not feasible)?

rownage
  • 2,392
  • 3
  • 22
  • 31

4 Answers4

8

One idea: You can register a Protocol handler to launch your app with the required parameters.

chrisaut
  • 1,076
  • 6
  • 17
  • This works. It's how programs like iTunes and Spotify let you open links from websites. – Tim Rogers Aug 24 '11 at 14:33
  • Thanks for the fast response (and to others for recommending this). I'm looking into it now. – rownage Aug 24 '11 at 14:47
  • So, in this case, for every computer that I want to be able to run this on, I'd have to add a new registry key? – rownage Aug 24 '11 at 15:19
  • Essentially, yes. Your app (that needs to be installed anyways) should do this (and undo it on uninstall). – chrisaut Aug 24 '11 at 16:02
  • This was a good answer that would have met my needs, but the installed app (which is third-party) is to be downloaded during a previous part of the study, and the web app gets launched automatically at a certain part during the study. I just found some of this out myself. +1 regardless – rownage Aug 25 '11 at 18:43
3

There are a couple of ways to do this. One doesn't violate security (much).

You can download a file with a particular file type. That file type can be associated to the client program, so after clicking "ok" to download the file, the client program would launch. The downloaded file may or may not contain some data like the id of some object.

The alternative would be to resort to ActiveX, which does have security implications.

John Saunders
  • 160,644
  • 26
  • 247
  • 397
  • The only problem with file association is that it requires the user to click "Open" instead of "Save" or "Cancel". Just that one step makes it too complicated for some situations, depending on what you feel you can expect from your users. I posted an example utilizing ActiveX below, could you elaborate on possible security issues as a result of using this? – pseudocoder Aug 24 '11 at 15:03
  • Only that it requires the browser to permit ActiveX controls. This could permit some bad ActiveX control to run. – John Saunders Aug 24 '11 at 15:56
1

If you put your site in the IE Trusted or Intranet zone, the following Javascript will work just fine. I use this one internally to link our PC support DB search to our remote screen control software:

<script type="text/javascript" language="javascript">
    function runDameWare(strHostname, blControl) {
        var objShell = new ActiveXObject("Wscript.Shell");
        var strCommand = "C:\\Program Files\\Dameware\\dwrcc.exe -c: -h: -m:";
        strCommand += strHostname;
        if (blControl) {
            strCommand += " -v:";
        }
        objShell.Exec(strCommand);
    }
</script>

My understanding is that uploading the results of your work in the local program to the web server can be accomplished using the HttpWebRequest class, as shown in this article:

http://forums.asp.net/p/1482778/3464854.aspx


Edit: This is how I call the above function. Basically I'm just rendering a plain <a> element with the onclick attribute. There's probably a cleaner way to do it, but it works:

Markup:

<asp:TemplateField>
    <ItemTemplate>
        <%# RenderDameWareLinks(Eval("ResourceName"))%>
    </ItemTemplate>
</asp:TemplateField>

Code:

Protected Function RenderDameWareLinks(ByVal strHostname As String) As String
    Dim strFullLink As String = String.Empty
    Dim strViewLink As String = String.Empty
    strFullLink = "<a onclick=""runDameWare('" & strHostname & "', false);"">"
    strFullLink &= "<img alt=""Connect using DameWare"" src=""Image/dameware1.gif"" style=""padding: 2px;"" />"
    strFullLink &= "</a><br/>"
    strViewLink = "<a onclick=""runDameWare('" & strHostname & "', true);"">"
    strViewLink &= "<img alt=""Connect (View Only) using DameWare"" src=""Image/dameware2.gif"" style=""padding: 2px;"" />"
    strViewLink &= "</a>"
    Return strFullLink & strViewLink
End Function
pseudocoder
  • 4,314
  • 2
  • 25
  • 40
  • Where do you put that script so that it runs onclick? I'm having a heck of a time getting it to run once a button is clicked. – rownage Aug 24 '11 at 17:44
  • This worked wonderfully. Sorry it took a day to get around to coming back here. – rownage Aug 25 '11 at 18:39
0

Since the machine already needs to have this "hidden" program installed, why not just write a native application and install that and have the employee run that instead of your web application?

Steve
  • 8,469
  • 1
  • 26
  • 37