Solved

Process Class RedirectStandardError Crashing Application

Posted on 2012-04-02
1
693 Views
Last Modified: 2012-06-27
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

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()

Open in new window

0
Comment
Question by:weirddemon
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 1

Accepted Solution

by:
weirddemon earned 0 total points
ID: 37798674
I figured out the problem. When using UseShellExecute, the Process class ignores the working directory property. From 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
________
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Sometimes a user will call me frantically, explaining that something has gone wrong and they have tried everything (read - they have messed it up more and now need someone to clean up) and it still does no good, can I help them?!  Usually the standa…
In a recent article here at Experts Exchange (http://www.experts-exchange.com/articles/18880/PaperPort-14-in-Windows-10-A-First-Look.html), I discussed my nine-month sandbox testing of the Windows 10 Technical Preview, specifically with respect to r…
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question