Topic Options
#166389 - 11/16/09 05:37 PM [Request] Run as service object
Richard_Pikk


Registered: 08/29/07
Posts: 32
Okay, I'm not sure if this can be done, but here goes:

With the built-in Windows command line tool SC.EXE you can configure any application to run as a service in Windows. This works for creating and managing services, cool! However, only applications that can communicate with the Service Control Manager will actually be able to operate this way.

It would be great if there was an extension that could talk to the Service Control Manager and keep your application running when started as a service. It would be suitable for creating any sort of client/server program, where the server part wouldn't have to run in the context of a logged on user session.

Possible?

I know you can "wrap" your application in some form of third-party service handler product, but that method is pretty clunky.

Top
#166399 - 11/16/09 07:26 PM Re: [Request] Run as service object [Re: Richard_Pikk]
UrbanMonk


Registered: 05/20/08
Posts: 331
Loc: Southern U.S.A.
I've successfully been able to run my programs as a service by adding registry entries, but if you want to use that method you'll have to do your own research.

Top
#166446 - 11/17/09 04:10 AM Re: [Request] Run as service object [Re: UrbanMonk]
Richard_Pikk


Registered: 08/29/07
Posts: 32
I'm not an expert in this area as you can see, but it is my understanding that all the SC.EXE tool does is create the required registry keys in CurrentControlSet\services. I have tried adding the keys manually with the same result.

That result, by the way, is that the service is created and appears in the services list as one would expect, but when started it terminates shortly afterwards with the dialog The service did not respond to the start or control request in a timely fashion. The program actually runs for a few seconds before this happens, and my "research" into this error indicates that this is due to the program not responding to messages from the Service Control Manager.

I have found many threads in various forums where people are trying to run non-service applications (or even scripts) as services by creating entries for them in the registry and getting this error. The accepted solutions seem to be:

1. Use SRVANY.EXE from the Windows 2003 Resource Kit or a third party tool as a wrapper for your program or script.

2. Make your program behave like a service.

I'm trying to achieve the second solution. wink

If I'm wrong and there is another way to to this properly, I'd love some pointers on how to proceed.

Top
#166543 - 11/17/09 02:19 PM Re: [Request] Run as service object [Re: Richard_Pikk]
DJFuego


Registered: 07/01/06
Posts: 1126
Loc: UK
It's not possible to make a MMF2 application run as a service without the service wrapper Srvany.exe. This is because the executable is not the kind that can be run as a service natively.

CT would have to add the option as part of the MMF2 build to make the exe work as a service, possibly by bundling the wrapper in with the exe so it did everything automatically for you.

For now you can see my example for the lacewing server.
http://www.clickteam.com/epicenter/ubbthreads.php?ubb=showflat&Number=163978#Post163978

I don't think it's something an extenstion would be able to do.
_________________________
Regards

Ross

RAMRAIDERSOFTWARE

Top
#166580 - 11/17/09 05:35 PM Re: [Request] Run as service object [Re: Richard_Pikk]
UrbanMonk


Registered: 05/20/08
Posts: 331
Loc: Southern U.S.A.
Originally Posted By: Richard_Pikk
That result, by the way, is that the service is created and appears in the services list as one would expect, but when started it terminates shortly afterwards with the dialog The service did not respond to the start or control request in a timely fashion. The program actually runs for a few seconds before this happens, and my "research" into this error indicates that this is due to the program not responding to messages from the Service Control Manager.


You are correct about the fact that the service manager won't acknowledge that your app is running as a service, but it is still executed as one.

And as a result has access to everything an application running as a system process does, except of course communicate with service control manager.

Also the error you were talking about is not returned if the service is activated by restarting your computer. Windows simply suppresses it and states that the service isn't running although the executable itself is.

I suppose this goes against what you want though since you did mention a server application.


Edited by UrbanMonk (11/17/09 05:36 PM)

Top
#166820 - 11/19/09 11:18 AM Re: [Request] Run as service object [Re: UrbanMonk]
Richard_Pikk


Registered: 08/29/07
Posts: 32
DJFuego,
Nice example, seems to work great. I'm assuming this is the SRVANY.EXE from the Windows Server 2003 Resource Kit? Is it okay to distribute this file with your application?

UrbanMonk,
Good observation about the process running anyway, despite the service being listed as stopped. I haven't tried myself, but that won't work for me anyways. I need to be able to start and stop the service like normal.

Top


Site Links
Forum Index

Home Page
Online Store
Tutorials
Download Center
French Forum

Quick File Links
Multimedia Fusion 2
Updates - build 249
Standard Version
Developer Version

Extension Packs
Bonus Pack 1
Bonus Pack 2
z33z Extension Pack
LIJI Extension Pack

The Games Factory 2
Latest Update - build 249
Community Links
Fusion Wiki
MFA Repository
Klikdisc
The Daily Click
GameBuilder

GB Arcade
TDC Arcade
Madword

Extensions
Neatwares Extension List
Extension Updater

Lacewing & Moo Server
Klikfarm

Money from your games
Click Chat
17 People are chatting
Game Builder

Visit the GameBuilder Homepage

Recent Download

Splotches Demo

Latest News