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

  • Home
  • SEARCH
  • 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 7841299
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T16:04:17+00:00 2026-06-02T16:04:17+00:00

I need execute a program in the remote computer, so I created a service

  • 0

I need execute a program in the remote computer, so I created a service in order to call psexec (it’s crucial using the service). However, this service cannot call psexec.

Following the code:

            String cmd = "", arguments = "";
            cmd = @"C:\PsTools\psexec.exe";

            arguments = @"\\remoteComputer -u "user" -p "password" "C:\program.exe"";

            Process process = new Process();
            process.StartInfo.FileName = cmd;
            process.StartInfo.Arguments = arguments;

            process.StartInfo.UseShellExecute = false;
            process.StartInfo.RedirectStandardOutput = true;
            process.StartInfo.RedirectStandardError = true;
            process.StartInfo.CreateNoWindow = true;
            process.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;

            process.Start();
            result = process.StandardOutput.ReadToEnd();
            sError = process.StandardError.ReadToEnd();

            result += "Program has finished its execution";

Do anyone know why the service cannot call the psexec?

  • 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-02T16:04:17+00:00Added an answer on June 2, 2026 at 4:04 pm

    I had issues with psexec hanging too when running a batch file remotely. How about WMI? This worked for me when running something on a remote computer; it works for *.bat and *.exe too. You might need to click Project>Add Reference and choose “System.Management” on the .NET tab–the reference wasn’t there in VS 2010 until I manually added it.

            System.Management.ConnectionOptions connOptions =
                new System.Management.ConnectionOptions();
    
            connOptions.Impersonation = System.Management.ImpersonationLevel.Impersonate;
            connOptions.EnablePrivileges = true;
    
            string compName = "RemoteComputerName";
            System.Management.ManagementScope manScope =
                new System.Management.ManagementScope(
                    String.Format(@"\\{0}\ROOT\CIMV2", compName), connOptions);
            manScope.Connect();
    
            System.Management.ObjectGetOptions objectGetOptions =
                new System.Management.ObjectGetOptions();
    
            System.Management.ManagementPath managementPath =
                new System.Management.ManagementPath("Win32_Process");
    
            System.Management.ManagementClass processClass =
                new System.Management.ManagementClass(manScope, managementPath, objectGetOptions);
    
            System.Management.ManagementBaseObject inParams =
                processClass.GetMethodParameters("Create");
    
            inParams["CommandLine"] = @"c:\MyBatchFile.bat";
    
            System.Management.ManagementBaseObject outParams =
                processClass.InvokeMethod("Create", inParams, null);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to program a stateless server to execute remote methods. The client uses
I create a service in Delphi. I need this service to run my program.
I must be overlooking something terribly obvious. I need to execute a C program,
I have a .exe program (console app) written in .net. I need to execute
I need to execute a script in the background through a service. The service
I need to execute the given commands as root and sudo user using Java.
I need to execute a bash script on boot. To do so I created
I need to execute a program in Windows 7 that uses a file as
I need to execute a command from a program. The command line is ok,
I need to execute a program and retrieve its stdout output in c++. I'd

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.