Jump to content
Sign in to follow this  

Service Scripting

Recommended Posts


I created a script that I use as a syslog server. It receives all the syslog messages directed to my PC and then writes them to a access database.

I was wondering if there is a way to change my script so that it would run as a local service?

Share this post

Link to post
Share on other sites

To run a compiled AutoIt script as a service, you can use Instsrv.exe and Srvany.exe from Microsoft.

A UDF below may help to setup the service. Have Instsrv.exe and Srvany.exe in System32 directory.

Func _SrvAny($service, $fullpath, $hidden = 0)
; Adds a program, as a windows service.
; Requires $instsrv and $srvany to be assigned, full paths.
; e.g. _SrvAny ( 'ServiceName', 'FullPath_to_the_program' )
    Local $instsrv = @WindowsDir & '\System32\Instsrv.exe'
    Local $srvany = @WindowsDir & '\System32\SrvAny.exe'
    If FileExists($instsrv) And FileExists($srvany) Then
        RunWait($instsrv & ' ' & $service & ' "' & $srvany & '"', '', @SW_HIDE)
        Local $key = 'HKLM\SYSTEM\CurrentControlSet\Services\' & $service
        If RegRead($key, 'DisplayName') Then
            If $hidden Then RegWrite($key & '\Parameters', 'AppParameters', 'Reg_sz', '/hidden')
            Return RegWrite($key & '\Parameters', 'Application', 'Reg_sz', $fullpath)

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  


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.