473,321 Members | 1,669 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,321 software developers and data experts.

Cannot read psexec output

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
Nov 17 '07 #1
1 8409
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ü
ke*****@arcor.de

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."
Nov 17 '07 #2

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

Similar topics

8
by: baustin75 | last post by:
Posted: Mon Oct 03, 2005 1:41 pm Post subject: cannot mail() in ie only when debugging in php designer 2005 -------------------------------------------------------------------------------- ...
2
by: dennis.scales | last post by:
I'm trying to wrap a psexec command in a python script so I can capture the results and generate an exception report. The problem I'm having is that when I use x = os.popen("command") to do it, it...
19
by: lawrence k | last post by:
How can I find out where my script is outputting to the screen for the first time? My error logs are full of stuff like this: PHP Warning: session_start(): Cannot send session cache...
1
by: juergen | last post by:
Hi, there are many postings on this subject, I have read them put don't have an answer. I get these warnings: Cannot send session cookie - headers already sent in, but my php-scripts are okay. ...
4
by: vol30w60 | last post by:
Hi folks, I am trying to launch a program with PHP code. I am running Apache on Windows XP SP2. I am using the method noted here: http://us2.php.net/manual/en/function.exec.php#59428 To...
8
by: Fendi Baba | last post by:
I created an ASP.net page which opens excel. The data opens up correctly in MS office Excel 2007 but when we use a mahcine with MS Office 2003 we encountered a message, "Cannot read output file" Is...
0
by: Curious | last post by:
Hi, I'm not sure if this is the right place to post such command issues. If you know a better forum where people respond to messages fairly often, please let me know! Anyway, would appreciate...
1
by: porsch55 | last post by:
m_oProc = new Process(); ProcessStartInfo oInfo; oInfo = new ProcessStartInfo("\\\\" + sSourceServer + "\\" + Environment.SystemDirectory.Replace("C:", "C$") + "\\psexec.exe", " \...
4
by: =?Utf-8?B?emlubw==?= | last post by:
if I run the following from the command line as: C:\PsTools>psexec -u domain\myUser -p myPassword -i \\remoteServer cmd.exe it run successfully and it opens the command window on the remote...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.