Results 1 to 2 of 2

Thread: [RESOLVED] Process Class RedirectStandardError Crashing Application

  1. #1

    Thread Starter
    Wait... what? weirddemon's Avatar
    Join Date
    Jan 2009
    Location
    USA
    Posts
    3,826

    Resolved [RESOLVED] Process Class RedirectStandardError Crashing Application

    This is going to be a strange issue and I don't expect an answer, but I would appreciate any insight.

    I'm using Ghost32.exe to image HDDs within a Windows PE environment. With the release of WinPE 4.0, we can now use the 4.0 .NET framework. So in order to capture any errors that Ghost reports, I'm redirecting the standard error stream so I can review it later.

    But, when I implement those two lines of code (highlighted below), the application crashes. I've implemented error logging with the UnhandledException event of the application, but it never fires during this error. All other errors fire, but this one does not.

    So I ran it in normal Windows and I receive the following error:

    The system cannot find the file specified
    But when I comment out those lines, it opens just fine. So I'm a little confused.

    Any ideas, guys?

    Code:
    Dim p As New Process
            p.StartInfo.WorkingDirectory = "C:\Tools"
            p.StartInfo.FileName = "ghost32.exe"
            p.StartInfo.UseShellExecute = False
            p.StartInfo.RedirectStandardError = True
            p.Start()
            'Dim sr_err As StreamReader = p.StandardError
            p.WaitForExit()
    CodeBank contributions: Process Manager, Temp File Cleaner

    Quote Originally Posted by SJWhiteley
    "game trainer" is the same as calling the act of robbing a bank "wealth redistribution"....

  2. #2

    Thread Starter
    Wait... what? weirddemon's Avatar
    Join Date
    Jan 2009
    Location
    USA
    Posts
    3,826

    Re: Process Class RedirectStandardError Crashing Application

    I figured out the problem. When using UseShellExecute, the Process class ignores the working directory property.

    Quote Originally Posted by MSDN
    When UseShellExecute is false, the WorkingDirectory property is not used to find the executable. Instead, it is used only by the process that is started and has meaning only within the context of the new process. When UseShellExecute is false, the FileName property must be a fully qualified path to the executable.
    So I just passed the full path into the FileName property and it worked fine.

    Thanks
    CodeBank contributions: Process Manager, Temp File Cleaner

    Quote Originally Posted by SJWhiteley
    "game trainer" is the same as calling the act of robbing a bank "wealth redistribution"....

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width