Download file and run it automatically immediately after download

Qamar, Mo 101 Reputation points

How do I download a file and run it automatically immediately after download is completed?

A set of technologies in the .NET Framework for building web applications and XML web services.
1,474 questions
ASP.NET Web Forms
ASP.NET Web Forms
A part of the ASP.NET web application framework that can be used to create ASP.NET web applications.
547 questions
0 comments No comments
{count} votes

3 answers

Sort by: Most helpful
  1. Albert Kallal 3,801 Reputation points

    You can't do that anymore.

    At one time browsers did allow you to say click on a download link, and then choose run.

    but, these days, for reasons of security, it not really possible - and this ability is controlled by the browser settings, and not your web site code.

    It simply too high of a security risk. So, when you download a file?, then users will have to open their download folder, and choose run in most cases.

  2. Qamar, Mo 101 Reputation points

    I've got it to work... Here is the code.

                string toolsDir = System.Web.Hosting.HostingEnvironment.MapPath(ToolsDir);
                string toolexe = Path.Combine(toolsDir, ToolName);
                ProcessStartInfo psi = new ProcessStartInfo(toolexe);
                psi.WindowStyle = ProcessWindowStyle.Hidden;
                psi.CreateNoWindow = true;
                psi.Arguments = "-d:Dummy";
                Process p = Process.Start(psi);
    0 comments No comments

  3. AgaveJoe 22,626 Reputation points

    This design only works on your development machine because it is both the server and the client. Once deployed the code will execute on the server not the client machine.

    0 comments No comments