Jump to content

Install As Service


Recommended Posts

Global $objWMIService
Global $strComputer = "."

Const $OWN_PROCESS = 16;16 is own process
Const $INTERACTIVE = true;True changes the $Own_Process to 272 is interact with desktop
Const $NORMAL_ERROR_CONTROL = 1
Dim $Script, $SrvAny, $info, $Help

;Functions
_File_Open()
_Install_Service()
Func _File_Open()
    $FileOD = FileOpenDialog("Select SrvAny.exe File", "C:\", "EXE (*.exe)", 3)
    $File = FileOpen($FileOD, 0)
    $SrvAny = (Chr(34) & $FileOD  & chr(34) )
    If $File = -1 Then
        MsgBox(0, "Error", "Unable to open file, or no file selected !!")
    EndIf
EndFunc

Func _Install_Service()
    If $SrvAny = "" Then
    MsgBox(0,"Warning ", "Select the SvrAny.exe using the File Open first")
    Else
    MsgBox(0,"Information","This has to be activated only ONCE !!")
    $objWMIService = ObjGet("winmgmts:" & "{impersonationLevel=impersonate}!\\" & $strComputer & "\root\cimv2")
    $objService = $objWMIService.Get("Win32_BaseService")
    $errReturn = $objService.Create("_Au3@Service" ,"_Au3@Service" , $SrvAny, $OWN_PROCESS, $NORMAL_ERROR_CONTROL, _
    "Manual", $INTERACTIVE, "LocalSystem", ""  )
    EndIf
EndFunc

This is what i got from another script by searching tru this forums.

Ofc it can add services and also progs to start if it fails.

I want to create a real service - one that answers to the control commands from windows.

(Start?,Pause?,Stop?)

(myprob: it starts the service but it doesnt answer to control commands from windows. So how to receive those and how to "answer" ?)

can anyone help?

Link to comment
Share on other sites

The Scriptsnippets i showed are exactly copied from that thread.

It also does not what i want.

And its always the same issues with "other programs" i cant use them :)

I have only use for windows-integrated tools.

thanks anyways. anyone else with ideas on this? it could be really useful... since autoit programming is getting more and more complex and there'r coming more and more prof. programs up with this.

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...