locked
Local Intranet App needs to run app from web page RRS feed

  • Question

  • I have a vb.net executible app that resides on a group of users on our local network and I want to integrate an ASP.Net website that is also local to our internal users so they can select an item on the web page and it would open the executable passing in a parameter to the app (the vb.net app currently accepts these command line parameters I want to pass in).

    I have tried several types of examples ranging from ActiveXObject("WScript.Shell") in JS to Response.ConetentType in code behind. Although there are several posts saying you can run the shell command, I am not having any luck. All users have Win 7 Pro with IE8 and IE10.

    I know this is not a good way to do this, but I need to show a proof of concept, and just need to show it can work. I would like to ultinmately create an Accelerator of Add-in that could do this properly.

    Can anyone provide some help please?

    Here is snippets of code tried:

    code behind page with Grid of records:

    Private Sub GridView1_SelectedIndexChanged(sender As Object, e As EventArgsHandles GridView1.SelectedIndexChanged
        Response.Clear()
        Dim AppPath As String = "\\\\MyPC\\MyShare\\Winforms.exe"
        Dim TestApp As String = System.IO.Path.GetFileName(TripleAPath)
        Response.ContentType = "application/octet-stream"
        Response.AddHeader("content-disposition""filename=" + TestApp)
        Response.TransmitFile(AppPath)
        Response.End()
    End Sub

    And here is the js scriptmanager example I am trying to run from a button click. I get error about shell failure:

    Specifically automation error cannot create object, and here is the line in break mode:

    <script type="text/javascript"> function OpenApp() {var ws = new ActiveXObject("WScript.Shell"); ws.Exec("g:\\Winform.exe");} </script>
    

    And here is the code:

    Protected Sub Page_Load(ByVal sender As ObjectByVal e As EventArgsHandles Me.Load
        ' Define the name and type of the client script on the page. 
        Dim csName As [String] = "ButtonClickScript"
        Dim csType As Type = Me.[GetType]()
     
        ' Get a ClientScriptManager reference from the Page class. 
        Dim cs As ClientScriptManager = Page.ClientScript
     
        ' Check to see if the client script is already registered. 
        If Not cs.IsClientScriptBlockRegistered(csType, csName) Then
            Dim csText As New StringBuilder()
            csText.Append("<script type=""text/javascript""> function OpenApp() {")
            csText.Append("var ws = new ActiveXObject(""WScript.Shell""); ")
            csText.Append("ws.Exec(""g:\\Winform.exe"");")
            csText.Append("} </script>")
            cs.RegisterClientScriptBlock(csType, csName, csText.ToString())
        End If
     
    End Sub
    <input id="Button1" type="button" value="Click to open App" onClick="OpenApp()"/></p>
    


    Daniel R Gleason



    Tuesday, March 11, 2014 11:15 PM

All replies

  • Hi Daniel,

    this forum is for questions about html, css and scripting for website development.

    I have a vb.net executible app that resides on a group of users on our local network and I want to integrate an ASP.Net website that is also local to our internal users so they can select an item on the web page and it would open the executable passing in a parameter to the app (the vb.net app currently accepts these command line parameters I want to pass in).

    I think an ActiveX control or a hosted WBC in your VB.net app are the only viable solutions.


    Rob^_^

    Wednesday, March 12, 2014 2:31 AM