run exe from asp.net

  • Thread starter Thread starter Selen
  • Start date Start date
Selen said:
How can I run the program i.e.notepad.exe from asp.net c#?

Presumably, you mean you want to create a web page in ASP.NET which will
allow clients to run Notepad on their local machine? If so, just use WSH and
JavaScript:

<script>

var WshShell = new ActiveXObject("WScript.Shell")
WshShell.Run ("notepad.exe")

</script>
 
ProcessStartInfo psi = new ProcessStartInfo("notepad.exe");
psi.WindowStyle = ProcessWindowStyle.Hidden;

Process p = new Process();
p.EnableRaisingEvents = true;
p.Exited += new EventHandler(MyExited);
p.StartInfo = psi;
p.Start();

..... do stuff ...

p.Kill(); // Try killing the process

private void MyExited(object sender, EventArgs e)
{
MessageBox.Show("Exited process");
}

This will run notepad "hidden" (for illustration purposes).. Then p.Kill();
should kill it.
 
Back
Top