PC Review


Reply
Thread Tools Rate Thread

Cannot read psexec output

 
 
sjoshi
Guest
Posts: n/a
 
      17th Nov 2007
Hi All

I'm trying to use the Process/ProcessStartInfo class to use
sysinternals psexec tool to run a remote command but I'm unable to get
the output. The same command thru a DOS window runs fine on a remote
server.

The code is very simple...

_logger.Debug(string.Format("Filename: {0} Args: {1}", pathToExe,
args));

pc = new Process();

pc.StartInfo.FileName = pathToExe;
pc.StartInfo.Arguments = args;
pc.StartInfo.CreateNoWindow = true;
pc.StartInfo.UseShellExecute = false;
pc.StartInfo.RedirectStandardOutput = true;

if (pc.Start())
{
output = pc.StandardOutput.ReadToEnd();

pc.WaitForExit(20 * 1000);
}

return output;

But the process seems to wait forever. I even tried getting the log of
the parameters namely pathToExe and args and then running it manually
and that ran fine.

Any hints are appreciated.

thanks
Sunit
 
Reply With Quote
 
 
 
 
Kerem Gümrükcü
Guest
Posts: n/a
 
      17th Nov 2007
Hi Sunit,

why reinvent the wheel? See here:

[Debugging Tools for Windows]
http://www.microsoft.com/whdc/devtoo...nstallx86.mspx

It comes with a tool called "remote.exe" which can run a command
remotely and display its content (with interaction!) on your local system.
It's intended for the usage in driver development scenarios, but you can
use it wherever you think it will help you. And i think it is usefull in you
case,...

It just works fine and you dont have to redirect output stream with your
code.

BTW you should redirect any stream from the console to be able
to get any returned stream from the console output, this includes
also the errors and whatever your console outputs (socket, pipe,etc,...)

Regards

Kerem

---------
New Open Source Tools from me:
Calculate MD5 or SHA1 Hash for Files!
KHash Tools 1.0 Englisch:
http://download.chip.eu/de/KHash-Tools-1.0_1317168.html
http://entwicklung.junetz.de/project...ls%20v.1.0.zip
---------

Beste Grüsse / Best regards / Votre bien devoue

Kerem Gümrükcü
(E-Mail Removed)

Best Quote: "Ain't nobody a badass with a double dose
of rock salt...", Kill Bill Vol.2

Latest Open-Source Projects: http://entwicklung.junetz.de
Sign my guestbook: http://entwicklung.junetz.de/guestbook/

-----------------------
"This reply is provided as is, without warranty express or implied."


 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to read RunSQL output =?Utf-8?B?TGk=?= Microsoft Access ADP SQL Server 1 28th Mar 2007 03:16 AM
read datareader stream and read output parameters at the same time =?Utf-8?B?YmVu?= Microsoft ADO .NET 1 4th Jan 2005 01:31 PM
How do I read standard output from a cmd window PAPutzback Microsoft VB .NET 1 15th Dec 2004 10:39 PM
cd player cannot read final cd output =?Utf-8?B?Zy1vbmU=?= Windows XP MovieMaker 1 14th Jan 2004 07:12 AM
PSEXEC error Couldn't install PsExec service - HELP george Microsoft Windows 2000 1 28th Oct 2003 02:17 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:26 PM.