1

I am working on a kludge which is working locally but not after I deploy it to our server.

I have a web page which opens, runs an EXE and then closes the web page. Locally this works but after publishing to the server the EXE does not run. I have confirmed that the file path works from the server.

My Web Page code:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="EmailSignature_EXEC.aspx.cs" Inherits="_Default" %>

<html>
<head>
    <title></title>
<script>
function loaded()
{
    window.setTimeout(CloseMe, 500);
}

function CloseMe() 
{
    window.open('', '_self').close();
}
</script>
<script type="text/javascript">
</script>
</head>
<body onLoad="loaded()">
Hello!
    \\\\cmbfs02\\Software\\web\\EmailSignature_WPF\\EmailSignature_WPF.exe
</body>
</html>

C# Code:

using System.Diagnostics;

public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load()
    {
        var applicationPath = "\\\\cmbfs02\\Software\\web\\EmailSignature_WPF\\EmailSignature_WPF.exe";
        Process.Start(applicationPath);
        this.ClientScript.RegisterClientScriptBlock(this.GetType(), "Close", "window.close()", true);
    }
}

When I browse to my page on IIS I see the page appear and close after the Timeout but the Application doesn't run. If I copy the EXE path into Windows Explorer the application runs, but it does not from the method. Any help appreciated

5
  • Does the account that IIS is running the Application Pool under have the rights to access and execute the file? Commented Nov 20, 2017 at 16:52
  • I just updated the App Pool so that it runs as myself (an admin) rather than our service account, same results. Would I get any sort of message indicating failure? I get no feedback at all that the method was even hit, though again, locally it executes as expected on Page_Load Commented Nov 20, 2017 at 17:00
  • when you say that it "runs an exe" - where does it run the exe? from the name (WPF), it sounds like it is a UI application. Running that on the web-server (which is a service) is not going to work. Are you trying to bring up an exe on the client here? Commented Nov 20, 2017 at 17:00
  • It runs an EXE which is stored on a shared drive. \\\\cmbfs02\\Software\\web\\EmailSignature_WPF\\EmailSignature_WPF.exe This exe has been developed and compiled seperately, the EXE works if it were to be 'double clicked' from the server by following the path I specify. The end goal is to have a user navigate to the published Website which runs this EXE. Now, for testing, I am navigating to the site from the IIS Server but that would not be the true end use case. Does this answer your question? Commented Nov 20, 2017 at 17:05
  • 1
    @gruff but: is this application designed as a server-side headless tool that just does some processing on behalf of a web-server? or is it a client UI that the user expects to interact with? because what you're doing will only work for the first of those. Keep in mind: it isn't the client desktop that is running that Process.Start - it is your web-server, and more specifically the IIS / app-pool service account. It doesn't have a desktop upon which to display a UI. Commented Nov 20, 2017 at 17:07

1 Answer 1

1

It sounds like you're trying to launch a UI exe on the client, but what you're actually doing is executing it on the web server. If that's right, then fundamentally what you're trying to do is just ... not going to work. Ignoring the fact that the implementation would have to be completely different, browsers are explicitly designed not to run arbitrary executables from web servers - plus of course it would only work on certain OSes - presumably windows in this case.

A few years ago I might have said "look into ClickOnce for this" - but I have no idea whether that option is still supported or recommended.

Sign up to request clarification or add additional context in comments.

6 Comments

I understand what you mean about Browsers preventing this, but I am rewriting an old VB application we have in C#. The reason for the web browser piece is to mimic a Web App and avoid the "Run / Cancel" window when running the EXE. The reason for not using a Web App in the first place is that this is an application which generates Outlook Signature files, and the WordInterop COM library will not work when run on a server (Web App)
@gruff that doesn't change anything; a: the browser doesn't care about your motives, and b: the browser isn't even seeing this right now - everything here is happening on the server; all the browser is seeing is a tiny bit of html that closes itself immediately after loading - it doesn't see the Process.Start - that happens on the server
So is there an alternative to the Process.Start? The original application used this code, and it worked: <head runat="server"> <script language="javascript" > function todo() { //window.open('', '_self', ''); //window.close(); var theShell = new ActiveXObject("Shell.Application"); var theApp = "S:\\web\\EMS_2013\\EmailSignature1_2013.exe"; theShell.ShellExecute(theApp, "", "", "open", "1"); window.opener = '' window.close(); } </script> </head> <body onload="window.opener='';todo()"> </body>
@gruff whatever the alternative is: it won't involve Page_Load - that's strictly server-side. If you can script it via ActiveXObject, good luck - but I wouldn't expect most browsers to like that. IIRC an <a href> to a ClickOnce ".application" file on a network share used to work, but I haven't tried to do this in years
yes ClickOnce is still a thing... anyway to launch an executable from a browser, at least one actively-confirming user interaction (click) is required. more clicks if the exe is not publisher signed.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.