|
-
Apr 2nd, 2012, 05:19 PM
#1
[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
 Originally Posted by SJWhiteley
"game trainer" is the same as calling the act of robbing a bank "wealth redistribution"....
-
Apr 2nd, 2012, 05:40 PM
#2
Re: Process Class RedirectStandardError Crashing Application
I figured out the problem. When using UseShellExecute, the Process class ignores the working directory property.
 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
 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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|