Solved

Process Class RedirectStandardError Crashing Application

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
SQL Exceptions 3 40
VS.net 2010 11 26
VB 2005 Tooltips on Form Load Event 15 16
C# guarantee sql connection close 6 32
As the title indicates, I have done this before. It chills me everytime I update the OS on my phone, (http://www.experts-exchange.com/articles/18084/Upgrading-to-Android-5-0-Lollipop.html) because one time I did this and I essentially had a bricked …
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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.

863 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

22 Experts available now in Live!

Get 1:1 Help Now