Run Executable file in ASP.NET

In this blog post, i will provide a code snippet of how to run a process (in this case it is WindowsMediaPlayer.exe) which exists in your application root folder.

// Create An instance of the Process class responsible for starting the newly process.

System.Diagnostics.Process process1 = new System.Diagnostics.Process();

// Set the directory where the file resides

process1.StartInfo.WorkingDirectory = Request.MapPath("~/");

// Set the filename name of the file you want to open

process1.StartInfo.FileName = Request.MapPath("WindowsMediaPlayer.exe"); 

// Start the process

process1.Start();

 

 

Hope this helps,

Published 02 February 2007 12:15 PM by haissam

Comments

# shakil ahmed said on 23 April, 2007 06:25 AM

your article is very good.

but we want more information about how to call  exe in web form b'coz

i want to convert video file to flv using converter(using exe file).

so plz reply as soon as possible

                                                         thanks

# Alexei said on 05 September, 2007 02:09 PM

Thank you very much!!!

# Curtis said on 24 October, 2007 01:44 PM

Has this been answered yet?

# Nandkishore said on 18 November, 2007 09:32 AM

Hi,

Can you please tell me how can I call Outlook Express mail utility using asp.net web form?

Thanks & Regards,

Nandkishore

# Darshan ATwal said on 19 December, 2007 01:47 AM

you can call any local exe from webpage(asp.net) using javascript because it always runs on client side.

I hope it will be helpfull to you,

thanks

# Ihab said on 30 January, 2008 01:49 AM

hiHissam

thanks for this fruitfull article

but I wrote code to run txt file and it is working on the server it self using http://localhost

but when i tried to run from client using http://servername

nothing appears

this is the code

ProcessStartInfo processStartInfo = new ProcessStartInfo();

       processStartInfo.FileName = @"c:\WINDOWS\system32\notepad.exe";

       processStartInfo.Arguments = @"c:\test.txt";

       Process.Start(processStartInfo);

# bhupesh said on 12 February, 2008 05:49 AM

execute exe

# haissam said on 14 March, 2008 05:42 AM

Ihab Make sure that ASPNET account (WINDOWS 2000/XP) has right permission on the folder containing the exe file you want to execute and the location of the file you want to open. But i'm not sure what you are trying to do in your case. Give me more details to help you more.

# dvdclone said on 29 April, 2008 12:00 AM

Gosh provides an alternate way to run command- line Groovy scripts, as well as a simplified way to write Windows Services ( WinNT Services ) using Groovy. Gosh treats scripts the same, whether they are run from the command- line or as a service (including

# mxdev said on 02 September, 2008 04:45 PM

I have similar problem to run application on server side

and i solved it like this:

1. change local policies for APSNET user:

in WinXP: run secpol.msc

go to Local Policies->User Rights Assignment

find "Deny log on locally" and remove ASPNET user from it.

then find "Deny logon locally" and remove ASPNET user from it.

after that this code  will work

ProcessStartInfo processStartInfo = new ProcessStartInfo();

      processStartInfo.FileName = @"c:\WINDOWS\system32\notepad.exe";

      processStartInfo.Arguments = @"c:\test.txt";

      Process.Start(processStartInfo);

more details:

mxdev.blogspot.com/.../asp-net-run-application-exe-from-aspnet.html

Developer Blog - Mxdev - Personal Blog of Max Ivak; IT Management, Software development, Databases, Web solutions, Database optimization

# mxdev said on 02 September, 2008 05:05 PM

1. change local policies for APSNET user:

in WinXP: run secpol.msc

go to Local Policies->User Rights Assignment

find "Deny log on locally" and remove ASPNET user from it.

then find "Deny logon locally" and remove ASPNET user from it.

2. Security for files.

if your application needs also to work with files (open, save, etc) you have to change security settings for the folders to allow user ASPNET modify nedeed files.

to do this:

- In Explorer right button mouse click the folder and select "Properties"

- In Security tab, add "ASPNET" in and give desired permissions (Read, Write, Execute, etc).

# haissam said on 03 September, 2008 01:55 AM

mxdev thanks for sharing your information!

# vin said on 17 August, 2009 09:14 AM

Hi,

I alos looking for some solution to run exe of custom win.net application. this custom exe  resides on server1 and my ASP.net application is running on webserver say server2.

Is it possible?

Any solution to this?

Thanks

Vin

# Chirag said on 18 August, 2009 12:18 AM

Nice example thanks keep it up :)

# prasad said on 25 September, 2009 05:03 AM

this code run locally but does not run in server i tried by gving full permission to aspnet account does not work.anybody have any idea how to run execute process from server

This site

Search

Go

This Blog

Syndication

Sponsors

  • MaximumASP
  • Breaking News
  • Find a Job
  • Social Bookmarking
    Tidebuy Reviews
    Online Shopping
    asp.net hosting
    UK online local dating