running a external program on server side



Hi there,
I have my webpage written in C# and I am going to run an external
program within the web page. I have my code like

using System;
using System.Diagnostics;

namespace NRP
public class RP:System.Web.UI.Page
public void tryit()
ProcessStartInfo Info = new ProcessStartInfo();

Info.FileName = "A.exe"; // here A.exe will create a new file
on server side
Info.WorkingDirectory = "D:\\temp";
Process Proc ;

Proc = Process.Start(Info);
catch(System.ComponentModel.Win32Exception eee)
// error here

I test the code on the local IIS and it works. However, when I put the
code and the DLL on the webserver, it didn't work. I guess it is becase
I didn't set the path of the program properly, but I have no idea how
to set WorkingDirectory properly on server side while I didn't know the
exact path.

Eliyahu Goldin

Create a folder in your virtual directory and use it as a working directory.
You can get the physical path with the MapPath method.

Note that it is likely that the problem is not in missing path. You may be
encountering a security problem of the account not having enough
rights for accessing and running the external application.



Thanks. It works! I try two cases

1) I written a little program in C to create a text file on the server
side. Everything is all right!
2) I try to run another program on server side, it is veeeery slow and
output nothing, no error was outputted. !?

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question