running a external program on server side

Discussion in 'ASP .Net' started by wakun@wakun.com, Mar 13, 2006.

  1. Guest

    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 ;

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

    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.
     
    , Mar 13, 2006
    #1
    1. Advertising

  2. 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 asp.net account not having enough
    rights for accessing and running the external application.

    Eliyahu

    <> wrote in message
    news:...
    > 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 ;
    >
    > try
    > {
    > Proc = Process.Start(Info);
    > }
    > catch(System.ComponentModel.Win32Exception eee)
    > {
    > // error here
    > return;
    > }
    > }
    > }
    >
    > 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, Mar 13, 2006
    #2
    1. Advertising

  3. Guest

    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. !?
     
    , Mar 13, 2006
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Cédric Rossé
    Replies:
    2
    Views:
    1,043
    Cédric Rossé
    Sep 29, 2004
  2. Mythran
    Replies:
    2
    Views:
    515
    Mythran
    Jan 22, 2005
  3. Thor
    Replies:
    1
    Views:
    1,023
    Mikkel Heisterberg
    Jul 2, 2003
  4. Replies:
    0
    Views:
    445
  5. Jack
    Replies:
    3
    Views:
    216
Loading...

Share This Page