473,405 Members | 2,167 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

PRB - UseShellExecute option does not return STD-ERR

ATS
PRB - UseShellExecute option does not return STD-ERR

Please help,

I'm using the Process class to start an external process that "may" fail,
for all kinds of reasons, but in particular, it may fail because it needs
DLLs in its path. Normally if one manually launched such a process it would
show a dialog denoting the DLL it could not find. When I use the Process
class and specify the following on the ProcessStartInfo, the STD-ERR and
STD-OUT do not return the error message.

===============================
Process_MyThingy = new System.Diagnostics.Process();
ProcessStartInfo_MyThingy = new System.Diagnostics.ProcessStartInfo();

ProcessStartInfo_MyThingy.FileName = csTargetPath;
ProcessStartInfo_MyThingy.RedirectStandardError = true;
ProcessStartInfo_MyThingy.RedirectStandardInput = true;
ProcessStartInfo_MyThingy.RedirectStandardOutput = true;
ProcessStartInfo_MyThingy.UseShellExecute = false;

Process_MyThingy.StartInfo = ProcessStartInfo_MyThingy;

if (!Process_MyThingy.Start())
{
csERR =
"The MyThingy object failed to start. The file may be corrupt
and/or somehow a " +
"previous instance of the MyThingy object is still running and
is preventing further " +
"instances from running";
throw(new Exception(csERR));
}

StreamReader_StdOut = Process_MyThingy.StandardOutput;
StreamReader_StdErr = Process_MyThingy.StandardError;

if (Process_MyThingy.HasExited && (Process_MyThingy.ExitCode != 0))
{
csERR = StreamReader_StdErr.ReadToEnd();

if (IsBlank(ref csERR))
{
csERR = StreamReader_StdOut.ReadToEnd();
}

if (IsBlank(ref csERR))
{
csERR =
"The MyThingy object has ended immediately after launching,
but it could not be " +
"examined to determine if it successfully started not. One
likely cause of this " +
"situation is that the MyThingy object is missing needed DLLs
and resources it " +
"needs in order to run";
}

throw(new Exception(csERR));
}
===============================

From that code snippet, if it is used to launch an EXE that will not be able
to find a needed DLL, such that the EXE would otherwise show the dialog
denoting the DLL it was missing, then the code snippet will not get any
feedback whatsoever in STD-OUT or STD-ERR.

By the way, the "IsBlank" function is a simply function that just checks to
see if a string is empty or only comprised of white-space characters like
\t\r\n, etc.

How can I get the DLL missing error without showing the dialog, and/or go
ahead and let the dialog show, but I still need to redirect the STD-IN, OUT,
and ERR?
Nov 17 '05 #1
3 1778
You are not going to get anything on STDOUT or STDERR if the program
shows a dialog. The dialog is not connected to the STDERR or STDOUT stream
in any way.

If you are looking for an error, then the program needs to provide it in
some way. You could look for a dialog with a specific title, but that's not
a very sure-fire way of getting the information you need.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"ATS" <AT*@discussions.microsoft.com> wrote in message
news:5F**********************************@microsof t.com...
PRB - UseShellExecute option does not return STD-ERR

Please help,

I'm using the Process class to start an external process that "may" fail,
for all kinds of reasons, but in particular, it may fail because it needs
DLLs in its path. Normally if one manually launched such a process it
would
show a dialog denoting the DLL it could not find. When I use the Process
class and specify the following on the ProcessStartInfo, the STD-ERR and
STD-OUT do not return the error message.

===============================
Process_MyThingy = new System.Diagnostics.Process();
ProcessStartInfo_MyThingy = new
System.Diagnostics.ProcessStartInfo();

ProcessStartInfo_MyThingy.FileName = csTargetPath;
ProcessStartInfo_MyThingy.RedirectStandardError = true;
ProcessStartInfo_MyThingy.RedirectStandardInput = true;
ProcessStartInfo_MyThingy.RedirectStandardOutput = true;
ProcessStartInfo_MyThingy.UseShellExecute = false;

Process_MyThingy.StartInfo = ProcessStartInfo_MyThingy;

if (!Process_MyThingy.Start())
{
csERR =
"The MyThingy object failed to start. The file may be corrupt
and/or somehow a " +
"previous instance of the MyThingy object is still running and
is preventing further " +
"instances from running";
throw(new Exception(csERR));
}

StreamReader_StdOut = Process_MyThingy.StandardOutput;
StreamReader_StdErr = Process_MyThingy.StandardError;

if (Process_MyThingy.HasExited && (Process_MyThingy.ExitCode != 0))
{
csERR = StreamReader_StdErr.ReadToEnd();

if (IsBlank(ref csERR))
{
csERR = StreamReader_StdOut.ReadToEnd();
}

if (IsBlank(ref csERR))
{
csERR =
"The MyThingy object has ended immediately after launching,
but it could not be " +
"examined to determine if it successfully started not. One
likely cause of this " +
"situation is that the MyThingy object is missing needed DLLs
and resources it " +
"needs in order to run";
}

throw(new Exception(csERR));
}
===============================

From that code snippet, if it is used to launch an EXE that will not be
able
to find a needed DLL, such that the EXE would otherwise show the dialog
denoting the DLL it was missing, then the code snippet will not get any
feedback whatsoever in STD-OUT or STD-ERR.

By the way, the "IsBlank" function is a simply function that just checks
to
see if a string is empty or only comprised of white-space characters like
\t\r\n, etc.

How can I get the DLL missing error without showing the dialog, and/or go
ahead and let the dialog show, but I still need to redirect the STD-IN,
OUT,
and ERR?

Nov 17 '05 #2
ATS
Thanks for the reply,

But I'm confused. If I do not reroute the STD-IN/OUT/ERR, the "DLL missing
Error Dialog" shows. But when I do reroute STD-IN/OUT/ERR, the dialog does
not show. Why is that so? If the "Process" class would just let the dialog
show, everything would be wonderful.
Nov 17 '05 #3
ATS
Anyone have any ideas on that last post of mine?
Nov 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Anon Email | last post by:
Hi people, Another question. In the code below, why is there a screen output? This part of the code: bool status = TheCalculator.Execute(input); is merely assigning the result of the...
8
by: Douglas | last post by:
**** Post for FREE via your newsreader at post.usenet.com **** Hello, The following code does not compile if line 3 is uncommented "using namespace std". I do not understand it. Could...
3
by: Pierre Rouleau | last post by:
The std::exception class defined in the Standard C++ <exception> header specifies that the constructors could throw any exception becuase they do not have a throw() specification. Why is that? ...
0
by: PattyB | last post by:
Hi, I am using useshellexecute to run a program from VB.NET. When I set UseShellExecute = False I can examine the stdout and stderror, which is great. However, UseShellExecute will choke, if...
2
by: Fei Yuan | last post by:
Please forgive me re-posting this question since I wasn't clear in my original post. ---- Starting an external process needs to pass it a ProcessStartInfo() object. ProcessStartInfo has a...
0
by: Philip Lowman | last post by:
I am in the process of trying to migrate a couple of build solutions to Visual Studio Express 2005 from VS 2003 Professional and I am running into a weird C/C++ runtime library linking issue when...
5
by: pkirk25 | last post by:
It looks like the Visuakl Studio Intellisense can see the various functions but its compiler cannot. I am well out of my depth with this error message. report.obj : error LNK2019: unresolved...
5
by: Jesper Schmidt | last post by:
Hi, I have a relatively large C++ code base, which requires that static initializers are called when a dll is loaded. This seems to work well for native code, but it does not work for files...
13
by: Protoman | last post by:
I'm getting an error: 10 C:\Dev-Cpp\Enigma.cpp no match for 'operator<' in 'i < (+cleartext)->std::basic_string<_CharT, _Traits, _Alloc>::end ()' Code: Enigma.hpp...
1
by: Nikhil.S.Ketkar | last post by:
Hi, Does the following construct qualify as overloading on return type ? If not, in what way ? I overloaded the type conversion operator and used pointers to member functions. Its pretty...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.