GEOSoft Posted May 25, 2008 Author Share Posted May 25, 2008 (edited) It's there now. Thanks. Question: Do you need ProcessWaitClose($sServiceName) after _Service_Delete()?Not as far as I'm aware but it shouldn't hurt to put it in there or even use something like While _ServiceExists("service") Sleep(10) Wend Edit: I should have added that it is preferable that you check to see if a process is active and if it is then close it before attempting a delete. Also take note that some process can not be closed. Edited May 25, 2008 by GEOSoft George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
engine Posted May 25, 2008 Share Posted May 25, 2008 Not as far as I'm aware but it shouldn't hurt to put it in there or even use something like While _ServiceExists("service") Sleep(10) Wend Edit: I should have added that it is preferable that you check to see if a process is active and if it is then close it before attempting a delete. Also take note that some process can not be closed. If my memory doesn't fail me, my process was running as a service and couldn't be closed. Using your function _Service_Delete() alone, closes the process and deletes the associated service altogether. Kind regards. My contributions:Local account UDF Registry UDFs DriverSigning UDF Windows Services UDF [url="http://www.autoitscript.com/forum/index.php?showtopic=81880"][/url] Link to comment Share on other sites More sharing options...
GEOSoft Posted May 25, 2008 Author Share Posted May 25, 2008 If my memory doesn't fail me, my process was running as a service and couldn't be closed. Using your function _Service_Delete() alone, closes the process and deletes the associated service altogether.Kind regards.That's really what it should do so it seems to be working as intended.Just remember to check for @Error If it equals 1 then the function failed. George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
engine Posted May 25, 2008 Share Posted May 25, 2008 Hi GEOSoft. Please pay attention to this code: Func _Service_Delete($sServiceName, $Computer = "localhost") $Service = ObjGet("winmgmts:\\" & $Computer & "\root\cimv2") If _Service_Exists($sServiceName) AND IsObj($Service) Then $sItems = $Service.ExecQuery ("Select * from Win32_Service where name like '"& $sServiceName &"'") For $objService In $sItems $objService.StopService ($objService.Name) $objService.Delete ($objService.Name) Return Next EndIf Return SetError(1) EndFunc ;<==> _Service_Delete() Do you really need the "_Service_Exists($sServiceName)" part? It will work just fine if you omit it. The "IsObj($Service)" part I understand. But if you know for sure that the $Service variable is always an object, you can also skip this part. You aren't checking this on the other service related functions too. Plus if you had that before I might even not notice that the previous version wasn't working. Kind regards. My contributions:Local account UDF Registry UDFs DriverSigning UDF Windows Services UDF [url="http://www.autoitscript.com/forum/index.php?showtopic=81880"][/url] Link to comment Share on other sites More sharing options...
GEOSoft Posted May 25, 2008 Author Share Posted May 25, 2008 Hi GEOSoft. Please pay attention to this code: Func _Service_Delete($sServiceName, $Computer = "localhost") $Service = ObjGet("winmgmts:\\" & $Computer & "\root\cimv2") If _Service_Exists($sServiceName) AND IsObj($Service) Then $sItems = $Service.ExecQuery ("Select * from Win32_Service where name like '"& $sServiceName &"'") For $objService In $sItems $objService.StopService ($objService.Name) $objService.Delete ($objService.Name) Return Next EndIf Return SetError(1) EndFunc ;<==> _Service_Delete() Do you really need the "_Service_Exists($sServiceName)" part? It will work just fine if you omit it. The "IsObj($Service)" part I understand. But if you know for sure that the $Service variable is always an object, you can also skip this part. You aren't checking this on the other service related functions too. Plus if you had that before I might even not notice that the previous version wasn't working. Kind regards. I put that in as a safety valve when I sent you the test file and forgot to remove it. I'll take care of it tomorrow (actually that's later today since it's 02:30 hours) and thanks for pointing it out. George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
engine Posted May 25, 2008 Share Posted May 25, 2008 I put that in as a safety valve when I sent you the test file and forgot to remove it. I'll take care of it tomorrow (actually that's later today since it's 02:30 hours) and thanks for pointing it out.Sure.Regards. My contributions:Local account UDF Registry UDFs DriverSigning UDF Windows Services UDF [url="http://www.autoitscript.com/forum/index.php?showtopic=81880"][/url] Link to comment Share on other sites More sharing options...
engine Posted June 4, 2008 Share Posted June 4, 2008 (edited) I found that I need "ProcessWaitClose()" after _Service_Delete(). Otherwise I can't perform "regsvr32" or "FileDelete()" functions on files being used by the service, with success. So I am proposing the following modifications to these functions: Func _Service_Delete($sServiceName, $Computer = "localhost") $Service = ObjGet("winmgmts:\\" & $Computer & "\root\cimv2") $sItems = $Service.ExecQuery ("Select * from Win32_Service where name like '"& $sServiceName &"'") For $objService In $sItems If $objService.AcceptStop Then $objService.StopService ($objService.Name) ProcessWaitClose($objService.ProcessID) EndIf $objService.Delete ($objService.Name) Return Next Return SetError(1) EndFunc ;<==> _Service_Delete()oÝ÷ Ø Ýjëh×6Func _Service_Stop($sServiceName, $Computer = "localhost") $Service = ObjGet("winmgmts:\\" & $Computer & "\root\cimv2") $sItems = $Service.ExecQuery("Select * from Win32_Service Where State = 'Running' And name like '"& $sServiceName &"'") For $objService In $sItems If Not $objService.AcceptStop Then Return SetError(-2) $objService.StopService($objService.Name) ProcessWaitClose($objService.ProcessID) Return Next Return SetError(-1) EndFunc ;<==> _Service_Stop() I think it is best to have this implemented in the functions themselves. The "IsObj()" part in the _Service_Delete() function is totally unneeded, so I removed it. Kind regards. Edited June 4, 2008 by engine My contributions:Local account UDF Registry UDFs DriverSigning UDF Windows Services UDF [url="http://www.autoitscript.com/forum/index.php?showtopic=81880"][/url] Link to comment Share on other sites More sharing options...
GEOSoft Posted June 4, 2008 Author Share Posted June 4, 2008 I found that I need "ProcessWaitClose()" after _Service_Delete(). Otherwise I can't perform "regsvr32" or "FileDelete()" functions on files being used by the service, with success. So I am proposing the following modifications to these functions: Func _Service_Delete($sServiceName, $Computer = "localhost") $Service = ObjGet("winmgmts:\\" & $Computer & "\root\cimv2") $sItems = $Service.ExecQuery ("Select * from Win32_Service where name like '"& $sServiceName &"'") For $objService In $sItems If $objService.AcceptStop Then $objService.StopService ($objService.Name) ProcessWaitClose($objService.ProcessID) EndIf $objService.Delete ($objService.Name) Return Next Return SetError(1) EndFunc ;<==> _Service_Delete()oÝ÷ Ø Ýjëh×6Func _Service_Stop($sServiceName, $Computer = "localhost") $Service = ObjGet("winmgmts:\\" & $Computer & "\root\cimv2") $sItems = $Service.ExecQuery("Select * from Win32_Service Where State = 'Running' And name like '"& $sServiceName &"'") For $objService In $sItems If Not $objService.AcceptStop Then Return SetError(-2) $objService.StopService($objService.Name) ProcessWaitClose($objService.ProcessID) Return Next Return SetError(-1) EndFunc ;<==> _Service_Stop() I think it is best to have this implemented in the functions themselves. The "IsObj()" part in the _Service_Delete() function is totally unneeded, so I removed it. Kind regards.Hmmmmmm. I thought I had already deleted that. Thanks. I'll look at these and update as required. George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
engine Posted June 9, 2008 Share Posted June 9, 2008 Here is an alternative for the _Service_StartType() function: Func _Service_StartType($sServiceName, $sStatus, $Computer = "localhost") Local $Service = ObjGet("winmgmts:\\" & $Computer & "\root\cimv2") Local $sItems = $Service.ExecQuery("Select * from Win32_Service Where name like '"& $sServiceName &"'") For $objService in $sItems Return $objService.ChangeStartMode($sStatus) Next Return SetError(-1) EndFunc ;<==> _Service_StartType() Available options for the $sStatus parameter are: "Boot" and "System" are valid only for system drivers. "Automatic", "Manual" and "Disabled". Client Requires Windows Vista, Windows XP, Windows 2000 Professional, or Windows NT Workstation 4.0 SP4 and later. Server Requires Windows Server 2008, Windows Server 2003, Windows 2000 Server, or Windows NT Server 4.0 SP4 and later. My contributions:Local account UDF Registry UDFs DriverSigning UDF Windows Services UDF [url="http://www.autoitscript.com/forum/index.php?showtopic=81880"][/url] Link to comment Share on other sites More sharing options...
GEOSoft Posted June 9, 2008 Author Share Posted June 9, 2008 Here is an alternative for the _Service_StartType() function: Func _Service_StartType($sServiceName, $sStatus, $Computer = "localhost") Local $Service = ObjGet("winmgmts:\\" & $Computer & "\root\cimv2") Local $sItems = $Service.ExecQuery("Select * from Win32_Service Where name like '"& $sServiceName &"'") For $objService in $sItems Return $objService.ChangeStartMode($sStatus) Next Return SetError(-1) EndFunc ;<==> _Service_StartType() Available options for the $sStatus parameter are: "Boot" and "System" are valid only for system drivers. "Automatic", "Manual" and "Disabled".Thanks engine I'll take a closer look at it. George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
engine Posted June 10, 2008 Share Posted June 10, 2008 I have been testing this alternative for the _Service_Create() function: ; $nServiceType Global Const $KERNEL_DRIVER = 0x1 Global Const $FILE_SYSTEM_DRIVER = 0x2 Global Const $ADAPTER = 0x4 Global Const $RECOGNIZED_DRIVER = 0x8 Global Const $OWN_PROCESS = 0x10 Global Const $SHARE_PROCESS = 0x20 Global Const $INTERACTIVE_PROCESS = 0x100 ; $nErrorType Global Const $NOT_NOTIFIED = 0 Global Const $USER_NOTIFIED = 1 Global Const $SYSTEM_RESTARTED = 2 Global Const $SYSTEM_STARTS = 3 Func _Service_Create($sServiceName, $sDisplayName, $sBinaryPath, $nServiceType = $OWN_PROCESS, _ $nErrorType = $USER_NOTIFIED, $nStartType = "Automatic", $sDesktopInteract = False, _ $sServiceUser = "LocalSystem", $sPassword = "", $sLoadOrderGroup = "NULL", $sComputerName = "localhost") Local $Service = ObjGet("winmgmts:\\" & $sComputerName & "\root\cimv2") Local $objService = $Service.Get("Win32_Service") Return $objService.Create($sServiceName, $sDisplayName, $sBinaryPath, $nServiceType, _ $nErrorType, $nStartType, $sDesktopInteract, $sServiceUser, $sPassword, $sLoadOrderGroup) EndFunc ;<==> _Service_Create() It works and can set more parameters than the one included in the "Services.au3" file. The object method allows to set dependencies, but I was unable to do it until now. They must be passed as Arrays and I don't know how to do it yet. My contributions:Local account UDF Registry UDFs DriverSigning UDF Windows Services UDF [url="http://www.autoitscript.com/forum/index.php?showtopic=81880"][/url] Link to comment Share on other sites More sharing options...
engine Posted June 10, 2008 Share Posted June 10, 2008 Here is a much better alternative for the _Service_Exists() function: Func _Service_Exists($sServiceName, $Computer = "localhost") Local $Service = ObjGet("winmgmts:\\" & $Computer & "\root\cimv2") Local $sItems = $Service.ExecQuery ("Select * from Win32_Service where name like '"& $sServiceName &"'") For $objService In $sItems Return 1 Next Return 0 EndFunc ;<==> _Service_Exists() This one can check a remote computer. While the previous one can't. That was the only function that didn't accept a computer name. You must include this one. Regards. My contributions:Local account UDF Registry UDFs DriverSigning UDF Windows Services UDF [url="http://www.autoitscript.com/forum/index.php?showtopic=81880"][/url] Link to comment Share on other sites More sharing options...
GEOSoft Posted June 10, 2008 Author Share Posted June 10, 2008 (edited) Here is a much better alternative for the _Service_Exists() function: Func _Service_Exists($sServiceName, $Computer = "localhost") Local $Service = ObjGet("winmgmts:\\" & $Computer & "\root\cimv2") Local $sItems = $Service.ExecQuery ("Select * from Win32_Service where name like '"& $sServiceName &"'") For $objService In $sItems Return 1 Next Return 0 EndFunc ;<==> _Service_Exists() This one can check a remote computer. While the previous one can't. That was the only function that didn't accept a computer name. You must include this one. Regards.Thanks again. That is a definite improvement. Just watch for one thing when you are writing for remote systems. Sometimes they will require an impersonation level to be set. I'm assuming that you have tested for that with this version. EDIT: I should have added that in other cases, setting an impersonation level will cause the function to fail Edited June 10, 2008 by GEOSoft George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
GEOSoft Posted June 10, 2008 Author Share Posted June 10, 2008 I have been testing this alternative for the _Service_Create() function: ; $nServiceType Global Const $KERNEL_DRIVER = 0x1 Global Const $FILE_SYSTEM_DRIVER = 0x2 Global Const $ADAPTER = 0x4 Global Const $RECOGNIZED_DRIVER = 0x8 Global Const $OWN_PROCESS = 0x10 Global Const $SHARE_PROCESS = 0x20 Global Const $INTERACTIVE_PROCESS = 0x100 ; $nErrorType Global Const $NOT_NOTIFIED = 0 Global Const $USER_NOTIFIED = 1 Global Const $SYSTEM_RESTARTED = 2 Global Const $SYSTEM_STARTS = 3 Func _Service_Create($sServiceName, $sDisplayName, $sBinaryPath, $nServiceType = $OWN_PROCESS, _ $nErrorType = $USER_NOTIFIED, $nStartType = "Automatic", $sDesktopInteract = False, _ $sServiceUser = "LocalSystem", $sPassword = "", $sLoadOrderGroup = "NULL", $sComputerName = "localhost") Local $Service = ObjGet("winmgmts:\\" & $sComputerName & "\root\cimv2") Local $objService = $Service.Get("Win32_Service") Return $objService.Create($sServiceName, $sDisplayName, $sBinaryPath, $nServiceType, _ $nErrorType, $nStartType, $sDesktopInteract, $sServiceUser, $sPassword, $sLoadOrderGroup) EndFunc ;<==> _Service_Create() It works and can set more parameters than the one included in the "Services.au3" file. The object method allows to set dependencies, but I was unable to do it until now. They must be passed as Arrays and I don't know how to do it yet.What is it that you are attempting to pass as an array? I ask because of a plan I have for eliminating array passing to any of the existing functions. George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
engine Posted June 10, 2008 Share Posted June 10, 2008 (edited) What is it that you are attempting to pass as an array? I ask because of a plan I have for eliminating array passing to any of the existing functions. The $sLoadOrderGroup = "NULL" is wrong. MS says it accepts null but I don't know how to pass it to the function, because I need to set it by default. It doesn't work with $sLoadOrderGroup = "" (empty string). (Edit: Problem solved with the Default keyword) The Create Method of the Win32_Service Class accepts two additional parameters. uint32 Create( [in] string Name, [in] string DisplayName, [in] string PathName, [in] uint8 ServiceType, [in] uint8 ErrorControl, [in] string StartMode, [in] boolean DesktopInteract, [in] string StartName, [in] string StartPassword, [in] string LoadOrderGroup, [in] string [] LoadOrderGroupDependencies, [in] string [] ServiceDependencies ); These are their descriptions: LoadOrderGroupDependencies Array of load-ordering groups that must start before this service. Each item in the array is delimited by NULL and the list is terminated by two NULL values. In Visual Basic or script you can pass a vbArray. If the pointer is NULL or if it points to an empty string, the service has no dependencies. Group names must be prefixed by the SC_GROUP_IDENTIFIER (defined in the Winsvc.h file) character to differentiate it from a service name, because services and service groups share the same namespace. Dependency on a group means that this service can run if at least one member of the group is running after an attempt to start all of the members of the group. ServiceDependencies Array that contains names of services that must start before this service starts. Each item in the array is delimited by NULL and the list is terminated by two NULL values. In Visual Basic or script you can pass a vbArray. If the pointer is NULL, or if it points to an empty string, the service has no dependencies. Dependency on a service means that this service can only run if the service it depends on is running. They aren't accepting AutoIt arrays. Except for arrays with a single element like $Array[1] = ["string"]. (Edit: Yes they are) This method doesn't support setting of the service description. Edited June 14, 2008 by engine My contributions:Local account UDF Registry UDFs DriverSigning UDF Windows Services UDF [url="http://www.autoitscript.com/forum/index.php?showtopic=81880"][/url] Link to comment Share on other sites More sharing options...
engine Posted June 10, 2008 Share Posted June 10, 2008 (edited) I worked around the above mentioned problems in this way: Edit: Deleted obsolete code. Edited June 14, 2008 by engine My contributions:Local account UDF Registry UDFs DriverSigning UDF Windows Services UDF [url="http://www.autoitscript.com/forum/index.php?showtopic=81880"][/url] Link to comment Share on other sites More sharing options...
GEOSoft Posted June 10, 2008 Author Share Posted June 10, 2008 I worked around the above mentioned problems in this way:<snipped>It works at least for Windows XP. But I don't know if doing it by editing the registry is the best way.No it isn't. I'll see what I can do with it later. George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
GEOSoft Posted June 10, 2008 Author Share Posted June 10, 2008 (edited) Updated with 4 new functions _Service_GetFilePath() _Service_GetPid() _Services_ListRunning() _Services_List_FromPid() Enjoy Edit: For _Services_List_FromPid(), use the PID as returned from _Service_GetPid(). I have not yet checked to see if the PID from a file works with it so this may change in the future. Edited June 10, 2008 by GEOSoft George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
engine Posted June 11, 2008 Share Posted June 11, 2008 No it isn't. I'll see what I can do with it later. Sorry. Try this one: expandcollapse popup; $nServiceType Global Const $KERNEL_DRIVER = 0x1 Global Const $FILE_SYSTEM_DRIVER = 0x2 Global Const $ADAPTER = 0x4 Global Const $RECOGNIZED_DRIVER = 0x8 Global Const $OWN_PROCESS = 0x10 Global Const $SHARE_PROCESS = 0x20 Global Const $INTERACTIVE_PROCESS = 0x100 ; $nErrorType Global Const $NOT_NOTIFIED = 0 Global Const $USER_NOTIFIED = 1 Global Const $SYSTEM_RESTARTED = 2 Global Const $SYSTEM_STARTS = 3 Global $nullArray[1] = [""] Func _Service_Create( _ $sServiceName, _ $sDisplayName, _ $sBinaryPath, _ $sDescription = "", _ $nServiceType = "", _ $nErrorType = "", _ $nStartType = "", _ $sDesktopInteract = "", _ $sServiceUser = "", _ $sPassword = "", _ $sLoadOrderGroup = "", _ $sLoadOrderGroupDependencies = "", _ $sDependencies = "", _ $sComputerName = @ComputerName _ ) If $nServiceType = "" Then $nServiceType = $OWN_PROCESS If $nErrorType = "" Then $nErrorType = $USER_NOTIFIED If $nStartType = "" Then $nStartType = "Manual" If $sDesktopInteract = "" Then $sDesktopInteract = False If $sServiceUser = "" Then $sServiceUser = "LocalSystem" If $sLoadOrderGroup = "" Then $sLoadOrderGroup = Chr(32) If $sLoadOrderGroupDependencies = "" Then $sLoadOrderGroupDependencies = $nullArray If $sDependencies = "" Then $sDependencies = $nullArray Local $Service = ObjGet("winmgmts:" & "{ImpersonationLevel=impersonate}!\\" & $sComputerName & "\root\cimv2") Local $objService = $Service.Get("Win32_Service") Local $eCode = $objService.Create( _ $sServiceName, _ $sDisplayName, _ $sBinaryPath, _ $nServiceType, _ $nErrorType, _ $nStartType, _ $sDesktopInteract, _ $sServiceUser, _ $sPassword, _ $sLoadOrderGroup, _ $sLoadOrderGroupDependencies, _ $sDependencies _ ) If $eCode = 0 Then RegWrite("\\" & $sComputerName & "\HKLM\SYSTEM\ControlSet001\Services\" & $sServiceName, "Description", "REG_SZ", $sDescription) If $sLoadOrderGroup = Chr(32) Then RegDelete("\\" & $sComputerName & "\HKLM\SYSTEM\ControlSet001\Services\" & $sServiceName, "Group") EndIf Return $eCode EndFunc ;<==> _Service_Create()oÝ÷ ØÚ-zÂ'yçZºÚ"µÍÌÍÜÐÛÛ][YHHÛÛ][YoÝ÷ Ú)ìµæ¡ö®¶sbb33c·46ö×WFW$æÖRÒgV÷C¶Æö6Æ÷7BgV÷C°oÝ÷ Úíä^û§rبÌ(mÂäë[¢Ølµ«^éí²Æ²¶¬jg«mN¢«²Ú¶*'Ì(®H§«¢+ØÀÌØíÍ1½=ÉÉɽÕÀôÅÕ½ÐìÅÕ½ÐoÝ÷ Ú+'ßÛ[z)àiǦ×)Û!¢é]²!iÛhrº"¶°¢¹®§uú+¶2-¥ªÚë^®Æ«z}ýµ§zb§zjmÊËkxØ^®Ê§m£ âµæ¥Øh±ê®¢ÒN§ªê-²Özg§¶Ëhuçâæyö®Ú®¢Ú®¢Ö§vf¤z+^jÈú+¶®±êÇz·¢±©ÞÅ©©æ®¶sbb33c¶æÖRÒgV÷C¶×6æ×6w"gV÷C°¢b33c¶F7ÆæÖRÒgV÷CµvæF÷w2ÖW76VævW"gV÷C°¢b33c·6W'f6UFÒ&öw&ÔfÆW4F"fײgV÷C²b3#µvæF÷w2ÆfRb3#´ÖW76VævW"b3#¶×6æ×6w"æWRgV÷C°¢b33c¶FW67&FöâÒgV÷Cµ6÷w2vWFW"÷W"g&VæG2&RöæÆæRæBÆWG2÷RfRöæÆæR6öçfW'6Föç2âgV÷C°¤FÒb33c¶Dw&÷W³%ÒÒ²gV÷Cµ4544E$ôÒ6Æ72gV÷C²ÂgV÷Cµ&ÆÆVÂ&&G&F÷"gV÷CµÐ¤FÒb33c¶E6W'f6U³%ÒÒ²gV÷Cµ'572gV÷C²ÂgV÷Cµ6Õ52gV÷CµÐ ¢b33c¶Òõ6W'f6Uô7&VFRb33c¶æÖRÂb33c¶F7ÆæÖRÂb33c·6W'f6UFÂb33c¶FW67&FöâÂgV÷C²gV÷C²Âb33c´äõEôäõDdTBÂgV÷C´F6&ÆVBgV÷C²ÂG'VRÂgV÷C²gV÷C²ÂgV÷C²gV÷C²ÂgV÷C²gV÷C²Âb33c¶Dw&÷WÂb33c¶E6W'f6R¤×6t&÷ÂgV÷C·FW7BgV÷C²Âb33c¶ I think this is a great improvement. Kind regards. My contributions:Local account UDF Registry UDFs DriverSigning UDF Windows Services UDF [url="http://www.autoitscript.com/forum/index.php?showtopic=81880"][/url] Link to comment Share on other sites More sharing options...
GEOSoft Posted June 13, 2008 Author Share Posted June 13, 2008 Updated again. Current function list; Function List; _Service_Create(); _Service_Delete(); _Service_EnumAnticede(); _Service_EnumDepends(); _Service_Exists(); _Service_GetDescription(); _Service_GetDetails(); _Service_GetFilePath(); _Service_GetPid(); _Service_GetStartMode(); _Service_GetState(); _Service_Pause(); _Service_PauseOK(); _Service_Resume(); _Service_Running(); _Service_SetStartMode(); _Service_Start(); _Service_StartType(); _Service_Stop(); _Service_StopOK(); _Services_GetDetails(); _Services_List_FromPID(); _Services_ListInstalled(); _Services_ListRunning() George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now