How do I call a hidden process from a web app ?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • malkin
    New Member
    • Apr 2009
    • 4

    How do I call a hidden process from a web app ?

    Hello all,

    I have a web application which needs to call a console application and capture the output of that execution process.

    What I have is the following:
    Code:
    ProcessStartInfo psi = new ProcessStartInfo();
    psi.WindowStyle = ProcessWindowStyle.Hidden;
    psi.FileName = "doTask.exe";
    psi.Arguments = "abc";
    psi.UseShellExecute = false;
    psi.CreateNoWindow = true;
    psi.RedirectStandardOutput = true;
    
    Process proc = new Process()
    proc.StartInfo = psi;
    proc.Start();
    string output = proc.StandardOutput.ReadToEnd();
    proc.WaitForExit();
    
    // print the output from this execution process on a web page.. etc
    The problem I have is that no matter which option I set (CreateNoWindow , UseShellExecute ..etc), the console application will always pop up when this web page executes. What have I missed ?

    However, I have tried to use the same code on a standalone windows app and it's working as expected. Just that when I run this code on a webpage, it just doesn't do what I expected.

    Thanks !!
    Last edited by Frinavale; Jun 1 '09, 03:02 PM. Reason: Added code tags. Please post code within [code] [/code] tags.
  • Frinavale
    Recognized Expert Expert
    • Oct 2006
    • 9749

    #2
    A console application has to run in a console.
    That's why the console is opened when you execute the console app.

    Why is this a problem?
    No web user is going to see a console application open and close on the server.

    Comment

    • malkin
      New Member
      • Apr 2009
      • 4

      #3
      In fact, the console application process is triggered in an ActiveX control which means the console application is already pre-installed in client's PC.

      It seems that the options (CreateNoWindow or WindowStyle) doesn't affect the ActiveX control when triggering a process.

      Comment

      • Frinavale
        Recognized Expert Expert
        • Oct 2006
        • 9749

        #4
        Hmm you never mentioned that you were using ActiveX in your original post.

        I'm not sure how to prevent this, sorry.

        Comment

        Working...