Solved

Process Class RedirectStandardError Crashing Application

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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

In this article we will discuss all things related to StageFright bug, the most vulnerable bug of android devices.
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
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.

724 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