Solved

Problem spawning a regular win32 application from NT service

Posted on 1998-07-16
7
252 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
[X]
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
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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
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.
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

707 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