Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Problem spawning a regular win32 application from NT service

Posted on 1998-07-16
7
Medium Priority
?
255 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
Industry Leaders: 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 400 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: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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…
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
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.
Screencast - Getting to Know the Pipeline
Suggested Courses

597 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