Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6170895
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T23:07:11+00:00 2026-05-23T23:07:11+00:00

I am experiencing a weird issue when attempting to run a .NET command line

  • 0

I am experiencing a weird issue when attempting to run a .NET command line tool remotely using PsExec.

  1. When running PsExec from command line, it runs and completes fine.

  2. When running it from a console application (creating a process,
    running PsExec.exe with the necessary arguments to it) — it is
    running OK.

  3. When running it from our in house custom tool that is
    used to run different tasks, it either times out or does not
    complete successfully.

Here is the code i am using:

Process p = new Process();

p.StartInfo.FileName = @"C:\PsExec.exe";
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.UseShellExecute = false;
p.StartInfo.CreateNoWindow = true;

string arg = "-snapshot -display C:\*.msi -s";

p.StartInfo.Arguments = @"\\10.161.203.106 -u user -p pwd -cf C:\FVT.exe " + arg;

Logger.Info(this, "Starting process");

p.Start();
var ended = p.WaitForExit(60 * 1000);

if (!ended)
{
    throw new Exception("Process timed out.");
}

Logger.Info(this, "Process ended");

using (StreamReader sr = p.StandardOutput)
{
    string buffer = sr.ReadToEnd();
    Logger.Info(this, buffer);
}

This code runs fine from cmd line, or from a standalone app!

I have no idea what else could be wrong here.

Our in house tool spawns a new thread and runs this code in it.

Update:

command line + args in command line window — working.
Same cmd + args, run as a Process with RedirectOutput – stalls and returns on timeout.

Could this be a bug in .NET ? (this happens for other progarms, batch files, etc).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T23:07:12+00:00Added an answer on May 23, 2026 at 11:07 pm

    I don’t know what the error is, but I have a hunch that if you redirect stderr (RedirectStandardError = true) and read the stderr stream (like you do with stdout) it will tell you. Alternatively, while debugging leave CreateNoWindow = false and maybe you’ll see the console message (especially if it is waiting for a keypress; otherwise it might disappear too quickly to notice).

    Note that you might need to set up async readers on stdout/stderr if the process isn’t terminating. You can do that either on extra threads, or via the OutputDataReceived / ErrorDataReceived events (you need to set EnableRaisingEvents to true also).


    If that still doesn’t work; you could try running with UseShellExecute=true. This means you won’t be able to redirect IO, so you might have to use > / >> etc to pipe the output to a file (ideally in temp), then read the file.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm experiencing an issue on a test machine running Red Hat Linux (kernel version
I'm experiencing a weird scrollbar issue. I'm building a page that uses jQuery and
Using PHP 5.3 I'm experiencing weird / non-intuitive behavior when applying empty() to dynamic
I am experiencing a weird scrolling issue and I was hoping someone could give
I'm diving into Ruby on Rails and I'm experiencing a weird bug, using Rails
Possible Duplicate: Core Data not saving NSString. Hey all! Currently experiencing a weird issue
I'm experiencing a really weird issue which I do not know how to solve.
I am experiencing some pretty weird output from some c code. Granted I am
I'm experiencing an issue managing threads on .Net 4.0 C#, and my knowledge of
I am experiencing a weird issue with the jquery-ui tab object. If I highlight

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.