Launching an application on remote machine.

Posted on 2004-03-23
Last Modified: 2013-11-20
Hi All,
Can any one tell me, how to launch an application (executable) on remote machine from my workstation(In office LAN)?

To do this I m doing following efforts....
1. Copying the application(xyz.exe file) on remote machine using CopyFile() API.
2. Copying a service ( RemoteExeService.exe written by me) on remote machine.
3. Installing, starting the RemoteExeService on remote machine. (from my local  workstation).
   Now I m putting some code in RemoteExeService to find & execute the application (xyz.exe). basically calling ShellExecute API to execute xyz.exe.
Now problem is that, whenever I m starting service on remote machine, the application ( xyz.exe) is not launching, but I can see this xyz.exe in processes of remote machine (appearing in windows Task manager).

 can any one of you give some sample code for service to launch this application ?
I have administrative privileges of remote machine. Even if I m testing it on my local machine the application is not launching.

I really want help to this problem and any usefull input to this problem will get points from me.

Thanks & Regard
Question by:GautamSYadav
  • 2
LVL 23

Expert Comment

ID: 10664665
Use CreateProcess() instead of ShellExecute() to specify the user's interactive window station and default desktop. See

Creating an Interactive Process

Author Comment

ID: 10664972
Thanks for reply.
I have tryed the CreateProcess(), but it is giving same results.
In the service, i m doing following....

creating a thread .......
CreateThread (0, 0, (LPTHREAD_START_ROUTINE )MyService, 0, 0, &ThreadId)

and this is the function Myservice()

     STARTUPINFO         si = { sizeof(STARTUPINFO) };
     si.lpDesktop = "WinSta0\\Default";
     si.cb = sizeof(STARTUPINFO);
     LPCTSTR szExecutablePath = _T("E:\\Public\\DllRegister.exe");
     TCHAR               szCmdLine [2*MAX_PATH];
     wsprintf ( szCmdLine, _T("\"%s\" /c /s"), szExecutablePath );
     fprintf (stdout, "Service started!\n");
    while (1)
          if (StopServing)
               fprintf (stdout, "Service stopped!\n");
      StoppedServing = 1;
      return 0;
         //WinExec(szExecutablePath, SW_SHOWMAXIMIZED);
//ShellExecute(NULL, "open" , "DllRegister.exe", "E:\\Public\\DllRegister.exe", (LPCTSTR)"E:\\Public", SW_SHOWNORMAL);
CreateProcess(NULL, szCmdLine, NULL, NULL, FALSE, NORMAL_PRIORITY_CLASS , NULL, "E:\\Public", &si, &pi);
        //Beep (1000, 300);
        //Sleep (700);
    return 0;

all three ShellExecute, CreateProcess and WinExec are giving same results.
Is this the right manner to do the same ?

If i m doing same in simple console application, the things are going well and able to launch application. but not working through service.

Thanks again

LVL 23

Accepted Solution

chensu earned 250 total points
ID: 10670167
"To create an interactive process as shown in this example, a service application must be logged in to the LocalSystem account."

Expert Comment

ID: 10873960
A service must have the ability to interact with the desktop if you want to display something. You can check the service by viewing the properties to see if the "Allow service to interact with desktop" is checked. You can also set this when you create the service. You can use dwServiceType and the SERVICE_INTERACTIVE_PROCESS bit to set this programatically. I have included the section from the help files that describes the function.


SC_HANDLE CreateService(
  SC_HANDLE hSCManager,  // handle to service control manager database
  LPCTSTR lpServiceName, // pointer to name of service to start
  LPCTSTR lpDisplayName, // pointer to display name
  DWORD dwDesiredAccess, // type of access to service
  DWORD dwServiceType,   // type of service
  DWORD dwStartType,     // when to start service
  DWORD dwErrorControl,  // severity if service fails to start
  LPCTSTR lpBinaryPathName,  // pointer to name of binary file
  LPCTSTR lpLoadOrderGroup,  // pointer to name of load ordering group
  LPDWORD lpdwTagId,     // pointer to variable to get tag identifier
  LPCTSTR lpDependencies,  // pointer to array of dependency names
  LPCTSTR lpServiceStartName, // pointer to account name of service
  LPCTSTR lpPassword       // pointer to password for service account

A set of bit flags that specify the type of service. You must specify one of the following service types. Value Meaning
SERVICE_WIN32_OWN_PROCESS Specifies a Win32-based service that runs in its own process.
SERVICE_WIN32_SHARE_PROCESS Specifies a Win32-based service that shares a process with other services.
SERVICE_KERNEL_DRIVER Specifies a driver service.
SERVICE_FILE_SYSTEM_DRIVER Specifies a file system driver service.

If you specify either SERVICE_WIN32_OWN_PROCESS or SERVICE_WIN32_SHARE_PROCESS, you can also specify the following flag. Value Meaning
SERVICE_INTERACTIVE_PROCESS  Enables a Win32-based service process to interact with the desktop.


Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
has77  challenge 9 71
FizzBuzz challenge 9 76
wordmultiple challenge 12 116
Making an alias 7 77
Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
This is a video describing the growing solar energy use in Utah. This is a topic that greatly interests me and so I decided to produce a video about it.

932 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now