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 8921311
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T06:30:29+00:00 2026-06-15T06:30:29+00:00

I have read several questions in StackOverflow about redirecting output/errors from application but It

  • 0

I have read several questions in StackOverflow about redirecting output/errors
from application but It could not help me.

I have developed an executable in C# code. It recovers software from system registry
and call a webservice to save it to our database.

Inside the executable we are printing messages with

Console.WriteLine(“Message from Executable”);

On the other hand we have a CRM application and I have written two win forms
that call psexec.exe with the desired parameters and this .exe is remotely
copied and launched on target machine.

If you use direct psexec call with that parameters in cmd.exe, we can see the psexec
execution banners and OUR executable output

Something like:

PsExec v1.98 – Execute processes remotely

Copyright (C) 2001-2010

Mark Russinovich Sysinternals – http://www.sysinternals.com

Enterprise software @ 2012

Message from application

Starting task in machine “XXXXXXX”

Recovering software list from registry

Program.exe exited on MACHINE with error code 0.

When I make the psexec call with .NET, I cant recover my application output, It
just shows:

PsExec v1.98 – Execute processes remotely

Copyright (C) 2001-2010

Mark Russinovich Sysinternals – http://www.sysinternals.com

Program.exe exited on MACHINE with error code 0.

I am assigning to Process class a delegate who is recovering async
data from process, but this information, is not there.

I paste some code to see If you can find the reason my C# Console application
output does not appear:

The command I launch is:

Dim CmdExe As String = "\\#MAQUINA# -u #USUARIO# -p #CLAVE# -s -c -f """ + executionPath + """"

Parametes -s (Run as system) -c (Copy local file to remote system) -f (force overwrite)

Private Sub LanzarProceso()
        CheckForIllegalCrossThreadCalls = False
        Dim Proceso As New Process
        AddHandler Proceso.OutputDataReceived, AddressOf CallbackProcesoAsync
        AddHandler Proceso.ErrorDataReceived, AddressOf ErrorDataReceivedAsync

        Dim startInfo As New ProcessStartInfo
        startInfo.FileName = execFile
        startInfo.Arguments = CmdExe.Replace("#MAQUINA#", txtFiltroMaquina.Text).Replace _
                                            ("#USUARIO#", txtUsuario.Text.Trim).Replace _
                                            ("#CLAVE#", txtClave.Text.Trim)
        Proceso.EnableRaisingEvents = True
        startInfo.UseShellExecute = False
        startInfo.RedirectStandardOutput = True
        startInfo.RedirectStandardError = True
        startInfo.CreateNoWindow = False
        Proceso.StartInfo = startInfo
        Proceso.Start()
        Proceso.BeginOutputReadLine()
        Proceso.BeginErrorReadLine()
        Proceso.WaitForExit()


    End Sub

Delegates handling data:

 Private Sub CallbackProcesoAsync(sender As Object, args As System.Diagnostics.DataReceivedEventArgs)

        If Not args.Data Is Nothing AndAlso Not String.IsNullOrEmpty(args.Data) Then
            If Not listtask.InvokeRequired Then
                listtask.Items.Add(args.Data.ToString)
            Else
                Dim d As New TextToControl(AddressOf AddToControl)
                listtask.Invoke(d, args.Data.ToString)
            End If

        End If

    End Sub

    Private Sub ErrorDataReceivedAsync(sender As Object, args As System.Diagnostics.DataReceivedEventArgs)
        If Not args.Data Is Nothing AndAlso Not String.IsNullOrEmpty(args.Data) Then
            If Not listtask.InvokeRequired Then
                listtask.Items.Add(args.Data.ToString)
            Else
                Dim d As New TextToControl(AddressOf AddToControl)
                listtask.Invoke(d, args.Data.ToString)
            End If

        End If
    End Sub

I checked the program is finishing correctly. THe c# executable has

Enviroment.Exit(0);

at the end of the execution

  • 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-06-15T06:30:30+00:00Added an answer on June 15, 2026 at 6:30 am

    Ok, the best workaround I found to get all the output between psexec and my c# application
    after execution is:

    Dim CmdExe As String =”\#MAQUINA# -u #USUARIO# -p #CLAVE# -s -c
    -f “”” + executionPath + “”” > outputFileCode.txt”

    This allow me to parse the standard output without having to change anything or calling
    my program directly, because I can`t do it.

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

Sidebar

Related Questions

I've read several stackoverflow questions about the issue, but none seem to work for
I have read several questions regarding this but I fear they may be out
I have read several posts about the configuration manager in VS2010 (or before) but
I have read several questions on this already, but I have tried their solution
I've read several questions regarding UAC and privilege elevation but I've not found a
I have, of course, read several questions with exactly this asked, but I have
I have read several articles and several stackoverflow.com posts about expression tree. It is
I have read through a number of similar questions on stackoverflow but am a
I have read several articles and questions on concept of foreign key vs independent
I have read several forums but can't find the solution to this. int sIndex

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.