Solved

Process Class RedirectStandardError Crashing Application

Posted on 2012-04-02
1
688 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
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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

708 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now