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
Solved

Problem spawning a regular win32 application from NT service

Posted on 1998-07-16
7
250 Views
Last Modified: 2013-11-20
Hello,

Using the sample code from "Creating a Simple Window NT Service in C++" by Nigel Thompson from Microsoft's technical article in the MSDN CDs, I created my own NT service that spawns another Win32 application called "ServerApp".  After the NT service starts,  the ServerApp is created using CreateProcess().

STARTUPINFO si;
PROCESS_INFORMATION pi;
ZeroMemory(&si, sizeof(si));
si.cb = sizeof(si);
CreateProcess(NULL, "C:\\ServerApp", NULL, NULL, FALSE,
                              0, NULL, NULL, &si, &pi);

However, for some reason, the ServeApp stays in a wait state and never completes the execution.  Even after the NT service is stopped, the ServeApp remains in the wait state.  I can't even kill the process.  How can I get the process to start?

Thanks,

Jennifer
0
Comment
Question by:jli
7 Comments
 
LVL 7

Expert Comment

by:psdavis
ID: 1319343
Have you tried ShellExecute?

ShellExecute( this->GetSafeHwnd( ), "open", strEngine, NULL, strDirectory, SW_SHOWMINIMIZED );

Phillip

0
 

Author Comment

by:jli
ID: 1319344
In NT Service, there is no Windows handle associated with the process.
0
 
LVL 8

Expert Comment

by:trestan
ID: 1319345
There is no problem in the codes you listed here. Would you provide more information about the case? Did you debug your code to see where the program blocked? Or email me your codes: trestan@hotmail.com
0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 1

Expert Comment

by:Rajkumar_R
ID: 1319346
I think the problem must be in your other exe ServerApp
0
 

Expert Comment

by:ahomer
ID: 1319347
try using  ---

if(::CreateProcess(NULL, "C:\\ServerApp", NULL, NULL, FALSE,
0, NULL, NULL, &si, &pi)){
   ::CloseHandle (pi.hThread);
   ::CloseHandle (pi.hProcess);
}            

0
 
LVL 15

Accepted Solution

by:
Tommy Hui earned 100 total points
ID: 1319348
Your problem does not come from CreateProcess, but from the special environment of services. Take a look at this URL for a more complete discussion of the problem.

http://www.microsoft.com/msj/0398/service2.htm


0
 

Author Comment

by:jli
ID: 1319349
Thank you.
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
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.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

860 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