Launching an application on remote machine.

Posted on 2004-03-23
Medium Priority
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
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 750 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

Get MongoDB database support online, now!

At Percona’s web store you can order your MongoDB database support needs in minutes. No hassles, no fuss, just pick and click. Pay online with a credit card. Handle your MongoDB database support now!

Question has a verified solution.

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

This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
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.
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses

777 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