Forum Moderators: open

Message Too Old, No Replies

running an .EXE file

         

itssankar

5:32 am on Aug 16, 2004 (gmt 0)

10+ Year Member



i want to run a .exe file while click on a link on my web page. how its possible am using asp.net.

harun

12:19 pm on Aug 16, 2004 (gmt 0)

10+ Year Member



Hello,
if you would like to run an exe file,
first, your web user must a execute access on the folder that contains the exe file. cgi folders generally have execute permissions.
second, if your executable file tries to read or write a resource that requires admin privilage, you must change the web user to admin user(by configuring your web server if you are the admin of that server.)

ProcessStartInfo is a very useful class to launch a process. Here is the small code sample

using System.Diagnostics;

ProcessStartInfo psi= new ProcessStartInfo();
Process process;
psi.FileName="cmd.exe";
psi.Arguments=@"/C"; // add its arguments to pass the parameters to executable file
psi.UseShellExecute=false;
psi.RedirectStandardOutput=true;
psi.CreateNoWindow=true; // it does not create a visible windows
psi.WorkingDirectory=@"c:\temp"; // if required
process=Process.Start(psi); // starts the process
while (process.HasExited!=true) // wait until it stops
{
}
process.Close(); // close the process