SumTingWong Posted December 5, 2004 Share Posted December 5, 2004 (edited) I have updated my service control functions to take advantage of the new DllOpen and DllClose functions. I have also added _CreateService and _DeleteService. All these functions are limited in one way or another and offer only the very basic service control so I suggest you read up on the Windows service control functions on MSDN for more information.The test script requires winvnc.exe and vnchooks.dll to be copied to the Windows directory. You can download UltraVNC from here. Get the zipped file from the Downloads page.test.au3ServiceControl.au3 Edited December 5, 2004 by pacman Dargonis 1 Link to comment Share on other sites More sharing options...
ezzetabi Posted December 5, 2004 Share Posted December 5, 2004 You are always great Pacman. A list of the new function for everyone that does know what expecting. Func _StartService($sComputerName, $sServiceName) Func _StopService($sComputerName, $sServiceName) Func _ServiceExists($sComputerName, $sServiceName) Func _ServiceRunning($sComputerName, $sServiceName) Func _CreateService($sComputerName, $sServiceName, $sDisplayName, _$sBinaryPath, ect...) Func _DeleteService($sComputerName, $sServiceName) I saw optional parameters you'll need the lastest beta version. Link to comment Share on other sites More sharing options...
archrival Posted February 4, 2005 Share Posted February 4, 2005 @pacman: Is there any way to tell if a service is paused? A paused service is technically running, but doesn't perform it's function. So in this case doing _ServiceRunning("", "lanmanworkstation") while that service is paused returns that it's running (which it is) but obviously you cannot view machines on your domain. I added a check in my domainview script to make sure that service is running when the program starts, but if it's paused, I don't know how so specify that (with your DllCall anyway, which I'd prefer to use, I love it!) Link to comment Share on other sites More sharing options...
andyvl Posted August 25, 2007 Share Posted August 25, 2007 probally I do something wrong. I put this ua3 file in my Include folder, but when I try to include it I got aut2exe error 'error: error opening the destination file' and according to the about I'm using scite4autoIt3 v 1.71 Link to comment Share on other sites More sharing options...
Developers Jos Posted August 25, 2007 Developers Share Posted August 25, 2007 (edited) probally I do something wrong. I put this ua3 file in my Include folder, but when I try to include it I gotaut2exe error 'error: error opening the destination file'and according to the about I'm usingscite4autoIt3 v 1.71Its taking about the Destination file, not an Include file.Please show all the info from the SciTE ouput pane when you get this error . Edited August 25, 2007 by JdeB SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
andyvl Posted August 26, 2007 Share Posted August 26, 2007 nevermind. Found the issue. There was still a instance of my process running. That caused the error Link to comment Share on other sites More sharing options...
logonui Posted February 8, 2008 Share Posted February 8, 2008 I am getting an error message when i try to start the service. Error 5 Access denied #include "ServiceControl.au3" $servicename = "Software Ban Utility" FileInstall("Y:\Scripts\BanScripts\20080208_SBanSVC\srvany.exe",@SystemDir,1) _CreateService("", $servicename, $servicename, @SystemDir, "LocalSystem","", 0x110) RegWrite("HKLM\SYSTEM\CurrentControlSet\Services\" & $servicename & "\Parameters", "SBan", "REG_SZ", @ScriptDir & "\SBanStudent.exe") RegWrite("HKLM\SYSTEM\CurrentControlSet\Services\" & $servicename, "SBan", "REG_DWORD", 0x110) any ideas? Link to comment Share on other sites More sharing options...
netegg Posted March 20, 2008 Share Posted March 20, 2008 (edited) why does not have a function _disableservice($computername,$servivename)? Edited March 20, 2008 by netegg Link to comment Share on other sites More sharing options...
MadBoy Posted March 20, 2008 Share Posted March 20, 2008 why does not have a function _disableservice($computername,$servivename)?Search on other service threads. I've posted one. My little company: Evotec (PL version: Evotec) Link to comment Share on other sites More sharing options...
keilamym Posted March 27, 2008 Share Posted March 27, 2008 Search on other service threads. I've posted one.Im hoping someone can assist me.. I was able to get the script to start and stop services, but for some reaason it will not stop or start the Windows Desktop Firewall. The service name is "Windows Firewall/Internet Connection Sharing (ICS)". I thought there was issues because of the spaced between the words but I've addded single quotes, double quotes, two single, two double, and single and a double, etc. Has anyone gotten this to work on the desktop firewall? For the people thats curious, Im on an account that runs blackice and rog machines run the desktop firewall. I do client health for SMS and run some of the tools we've built, i need to stop them both and stop mcafee. i have to stop mcafee just to run psexec. my current tool works but now were going to sccm and since some the items were hardcoded inside my scripts, i've changed everything to variables, collapsed many scripts into one, and creating a new wise GUI front-end. if anyone could assist me, I would appreciate it. This is the only issue, so far.Lavelle Link to comment Share on other sites More sharing options...
keilamym Posted March 27, 2008 Share Posted March 27, 2008 Im hoping someone can assist me.. I was able to get the script to start and stop services, but for some reaason it will not stop or start the Windows Desktop Firewall. The service name is "Windows Firewall/Internet Connection Sharing (ICS)". I thought there was issues because of the spaced between the words but I've addded single quotes, double quotes, two single, two double, and single and a double, etc. Has anyone gotten this to work on the desktop firewall? For the people thats curious, Im on an account that runs blackice and rog machines run the desktop firewall. I do client health for SMS and run some of the tools we've built, i need to stop them both and stop mcafee. i have to stop mcafee just to run psexec. my current tool works but now were going to sccm and since some the items were hardcoded inside my scripts, i've changed everything to variables, collapsed many scripts into one, and creating a new wise GUI front-end. if anyone could assist me, I would appreciate it. This is the only issue, so far.Lavellejust realised that i have to use PSKill and PsService for a different part of my tool so I'll just continue to use it for the windows firewallthanks anyway Link to comment Share on other sites More sharing options...
MadBoy Posted March 28, 2008 Share Posted March 28, 2008 just realised that i have to use PSKill and PsService for a different part of my tool so I'll just continue to use it for the windows firewall thanks anyway This is because you are using it wrong The service name that you have to work with is actually SharedAccess and not the long name you just posted. #Include <C:\Projects\Project.Au3\Includes\Service.au3> #Include <Array.au3> _ArrayDisplay(_ServGetDetails("SharedAccess")) $test = _ServStart("SharedAccess") MsgBox(0,"test", $test) This works for me My little company: Evotec (PL version: Evotec) Link to comment Share on other sites More sharing options...
redrider81 Posted August 1, 2008 Share Posted August 1, 2008 I have updated my service control functions to take advantage of the new DllOpen and DllClose functions. I have also added _CreateService and _DeleteService. All these functions are limited in one way or another and offer only the very basic service control so I suggest you read up on the Windows service control functions on MSDN for more information.The test script requires winvnc.exe and vnchooks.dll to be copied to the Windows directory. You can download UltraVNC from here. Get the zipped file from the Downloads page.What an AWESOME UDF!!! I searched all over for this functionality in a UDF and couldn't find it, so I wrote my own. Now I'm about to post my code and I find this which is way more complete. Why don't you call it a UDF?Why isn't it in example scripts? Why isn't it a UDF included in AutoIT? Why did I find these dog crap threads before instead of this perfect solution?!?!http://www.autoitscript.com/forum/lofivers...php?t15251.htmlhttp://www.autoitscript.com/forum/index.php?showtopic=17581Damn Damn Damn....Sighs... Oh kay, im over it now. but jeeze man, somebody put this somewhere easy to find.Alright, somebody just needs to build a GUI for this. Guess I'll do that. Link to comment Share on other sites More sharing options...
CosmicDan Posted August 20, 2008 Share Posted August 20, 2008 Great stuff, exactly what I needed and it worked like a charm. Well done! CosmicDan.com Link to comment Share on other sites More sharing options...
keilamym Posted December 7, 2010 Share Posted December 7, 2010 madboy... while this is 2years old, i figure i should still say thanks.. LOL Link to comment Share on other sites More sharing options...
TheDude69 Posted October 27, 2011 Share Posted October 27, 2011 I had found this function in the lates AutoIt package as an UDF but there is no documentation in the UDF help file. Especially I am looking for information about the parameter's of CreateService. Is there some documentation elsewhere? Thanks in advance regards TheDude69 Link to comment Share on other sites More sharing options...
BrewManNH Posted October 27, 2011 Share Posted October 27, 2011 (edited) Did you read the UDF header for that function? ;=============================================================================== ; Description: Creates a service on a computer ; Parameters: $sComputerName - name of the target computer. If empty, the local computer name is used ; $sServiceName - name of the service to create ; $sDisplayName - display name of the service ; $sBinaryPath - fully qualified path to the service binary file ; The path can also include arguments for an auto-start service ; $sServiceUser - [optional] default is LocalSystem ; name of the account under which the service should run ; $sPassword - [optional] default is empty ; password to the account name specified by $sServiceUser ; Specify an empty string if the account has no password or if the service ; runs in the LocalService, NetworkService, or LocalSystem account ; $nServiceType - [optional] default is $SERVICE_WIN32_OWN_PROCESS ; $nStartType - [optional] default is $SERVICE_AUTO_START ; $nErrorType - [optional] default is $SERVICE_ERROR_NORMAL ; $nDesiredAccess - [optional] default is $SERVICE_ALL_ACCESS ; $sLoadOrderGroup - [optional] default is empty ; names the load ordering group of which this service is a member ; Requirements: Administrative rights on the computer ; Return Values: On Success - 1 ; On Failure - 0 and @error is set to extended Windows error code ; Note: Dependencies cannot be specified using this function ; Refer to the CreateService page on MSDN for more information ;=============================================================================== Edited October 27, 2011 by BrewManNH If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
ricky Posted July 8, 2014 Share Posted July 8, 2014 (edited) Hello, I'm testing your script, but I have an error with the _StartService I'm using it with Windows 8.1 and I have an error 6 with the OpenService. Could you help me? ;=============================================================================== ; Description: Starts a service ; Syntax: _StartService($sServiceName) ; Parameter(s): $sServiceName - Name of service to start ; Requirement(s): None ; Return Value(s): On Success - Sets @error = 0 ; On Failure - Sets: @error = 1056: Already running ; @error = 1060: Service does not exist ; Author(s): SumTingWong ; Documented by: noone ;=============================================================================== Func _StartService($sServiceName) Local $arRet, $hSC, $hService, $lError = -1 $arRet = DllCall("advapi32.dll", "long", "OpenSCManager", "str", "", "str", "ServicesActive", "long", 0x0001) If $arRet[0] = 0 Then $arRet = DllCall("kernel32.dll", "long", "GetLastError") $lError = $arRet[0] Else $hSC = $arRet[0] $arRet = DllCall("advapi32.dll", "long", "OpenService", "long", $hSC, "str", $sServiceName, "long", 0x0010) If $arRet[0] = 0 Then $arRet = DllCall("kernel32.dll", "long", "GetLastError") $lError = $arRet[0] Else $hService = $arRet[0] $arRet = DllCall("advapi32.dll", "int", "StartService", "long", $hService, "long", 0, "str", "") If $arRet[0] = 0 Then $arRet = DllCall("kernel32.dll", "long", "GetLastError") $lError = $arRet[0] EndIf DllCall("advapi32.dll", "int", "CloseServiceHandle", "long", $hService) EndIf DllCall("advapi32.dll", "int", "CloseServiceHandle", "long", $hSC) EndIf If $lError <> -1 Then SetError($lError) EndFunc ;==>_StartService Thanks for your help Edited July 8, 2014 by ricky03 Link to comment Share on other sites More sharing options...
Krakatoa Posted August 2, 2014 Share Posted August 2, 2014 Hello, I'm testing your script, but I have an error with the _StartService I'm using it with Windows 8.1 and I have an error 6 with the OpenService. Could you help me? ;=============================================================================== ; Description: Starts a service ; Syntax: _StartService($sServiceName) ; Parameter(s): $sServiceName - Name of service to start ; Requirement(s): None ; Return Value(s): On Success - Sets @error = 0 ; On Failure - Sets: @error = 1056: Already running ; @error = 1060: Service does not exist ; Author(s): SumTingWong ; Documented by: noone ;=============================================================================== Func _StartService($sServiceName) Local $arRet, $hSC, $hService, $lError = -1 $arRet = DllCall("advapi32.dll", "long", "OpenSCManager", "str", "", "str", "ServicesActive", "long", 0x0001) If $arRet[0] = 0 Then $arRet = DllCall("kernel32.dll", "long", "GetLastError") $lError = $arRet[0] Else $hSC = $arRet[0] $arRet = DllCall("advapi32.dll", "long", "OpenService", "long", $hSC, "str", $sServiceName, "long", 0x0010) If $arRet[0] = 0 Then $arRet = DllCall("kernel32.dll", "long", "GetLastError") $lError = $arRet[0] Else $hService = $arRet[0] $arRet = DllCall("advapi32.dll", "int", "StartService", "long", $hService, "long", 0, "str", "") If $arRet[0] = 0 Then $arRet = DllCall("kernel32.dll", "long", "GetLastError") $lError = $arRet[0] EndIf DllCall("advapi32.dll", "int", "CloseServiceHandle", "long", $hService) EndIf DllCall("advapi32.dll", "int", "CloseServiceHandle", "long", $hSC) EndIf If $lError <> -1 Then SetError($lError) EndFunc ;==>_StartService Thanks for your help New autoit script compile 64bit + service function = error 6 '?do=embed' frameborder='0' data-embedContent>> OK is: 1) old 64bit (and 32bit) autoit 2) new 32bit autoit compile script 64bit 3.3.10.2 and new autoit script compile bug version? Why no repair? :-( Link to comment Share on other sites More sharing options...
BrewManNH Posted August 2, 2014 Share Posted August 2, 2014 10 year old script, new version of AutoIt, and you expect this to still work? If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator 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