Sign in to follow this  
Followers 0
NightHawk

Exe as Service

5 posts in this topic

How can an exe file compiled from Autoit code install and act itself as a Windows Service without any external program like srvany.exe ?

Topic is old , still i get no answer about the Exe being independent to behave like a Service......

Any idea..... ???

Share this post


Link to post
Share on other sites

Type in CMD sc create /?

Share this post


Link to post
Share on other sites

Already tried the SC.exe in Windows XP SP2....

The exe file 'doesn't respond appropriately' (as the error is) when the service is started.

I have used SC.exe to start the service and also the compmgmt.msc without success.

There may be some property of the exe file such that it responds to the operating system like a service should do.

I can't run any exe(written in any language) as a service, isn't it?

It may require some coding inside the Autoit script , I suppose........

I can't figure out whether any User Defined Functions exists........

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

NightHawk

The exe file 'doesn't respond appropriately' (as the error is) when the service is started.

Hmm...try this:

Global Const $SERVICES_ACTIVE_DATABASE = "ServicesActive"
Global Const $SC_MANAGER_CREATE_SERVICE = 0x0002
Global Const $SERVICE_ALL_ACCESS = 0xF01FF
Global Const $SERVICE_WIN32_OWN_PROCESS = 0x00000010
Global Const $SERVICE_INTERACTIVE_PROCESS = 0x00000100
Global Const $SERVICE_AUTO_START = 0x00000002
Global Const $SERVICE_ERROR_NORMAL = 0x00000001

$hSCManager = DllCall("advapi32.dll", "hwnd", "OpenSCManager", "str", "", _
                      "str", $SERVICES_ACTIVE_DATABASE, "dword", $SC_MANAGER_CREATE_SERVICE)
$hSCManager = $hSCManager[0]

$aCreate = DllCall("advapi32.dll", "hwnd", "CreateService", "hwnd", $hSCManager, "str", "MyService", "str", "MyNewService", _
                   "dword", $SERVICE_ALL_ACCESS, "dword", BitOR($SERVICE_WIN32_OWN_PROCESS, $SERVICE_INTERACTIVE_PROCESS), _
                   "dword", $SERVICE_AUTO_START, "dword", $SERVICE_ERROR_NORMAL, "str", "c:\test.exe", "str", "", "ptr", 0, _
                   "ptr", 0, "str", "LocalSystem", "str", "")

If $aCreate[0] Then MsgBox(64, "CreateService", "Service creating successful")

MSDN

Edited by rasim

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0