Execute Applications on Remote Systems

By | May 24, 2010

Running executable applications remotely is really simple as long as you know the credentials of the remote workstation you want to run it on.

So how would you do that?

Through the use of PsExec. So what is PsExec? PsExec is a telnet-replacement that lets you execute processes on other systems without having to installing a client software. PsExec is free and can be downloaded here.

Once you downloaded it you can easily run command prompt from that directory.


To give you an example lets say I want to run a console application located at “D:MyApplications” named “MyExecutable.exe” at the workstation which has the IP “10.10.1.255”. Now the username for that workstation is “user” and the password is “pass”.

So the command for it will be :

psexec.exe \10.10.1.255 -u user -p pass -c -f "D:MyApplicationsMyExecutable.exe"

So what does the switches mean?

-u : send the username where the application will run as.
-p : that’s the password of that user.
-c : by using this switch, it copies the specified program in the specified location to the remote system for execution.
-f : if file already exists on the remote system it still copies and overwrites it.


So with a little bit of imagination you can do lots with it like performing command line commands remotely or you can even run it from a C# or VB.Net application.

Like such

VB.Net

Dim sShellCommand = "c:PsExecpsexec.exe \10.10.1.255 -u user -p pass -c -f ""D:MyApplicationsMyExecutable.exe"""
Shell(sShellCommand, AppWinStyle.Hide)

C#.Net


System.Diagnostics.Process oProcess = new System.Diagnostics.Process();
oProcess.EnableRaisingEvents = false;
oProcess.StartInfo.FileName = "c:\PsExec\psexec.exe";
oProcess.StartInfo.Arguments = "\\10.10.1.255 -u user -p pass -c -f "D:\MyApplications\MyExecutable.exe"";
oProcess.Start();

So if you want to know what are the other switches just type PsExec and you will see all switches you might need

Recommended

2 thoughts on “Execute Applications on Remote Systems

  1. saugata

    That is fine. But the problem is in case of GUI applicaion, I can’t see the GUI it just create in TaskManager. How to see the GUI…I have also tried with “-i”
    My code is —
    ProcessStartInfo info = new ProcessStartInfo();

    info.FileName = @”C:GSMOS ProjectsPOCProductionActivityProductionActivityProductionActivityPsToolsPsExec.exe”;

    info.Arguments = @”\” + ServerName + @” -i -u -p C:\ProductionActivity\ExcelApplication”;

    info.RedirectStandardOutput = true;
    info.UseShellExecute = false;
    info.RedirectStandardError = true;
    info.WindowStyle = ProcessWindowStyle.Maximized;
    Process o = Process.Start(info);

    Please give me solution.

    Reply
    1. rsmacaalay

      You need to indicate who is the user running the desktop so it will be interactive in the current desktop session. From your code above who is the executing user you are seeing at the task manager?

      Reply

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.