bordomavi Posted August 22, 2013 Share Posted August 22, 2013 (edited) Hi. I want change windows services options. Change settings for automatic or manual or stop services with autoit. Can i build code for this ? Edited August 22, 2013 by bordomavi Link to comment Share on other sites More sharing options...
water Posted August 22, 2013 Share Posted August 22, 2013 There is a Services UDF available. My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
water Posted August 22, 2013 Share Posted August 22, 2013 Here is the >link. My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
bordomavi Posted August 22, 2013 Author Share Posted August 22, 2013 Here is the >link. #include <Services.au3> _Service_SetStartType _Service_Stop Func _Service_Stop("Service1", $sComputerName = "") Local $iSSM = _Service_SetStartType($sServiceName, $SERVICE_DISABLED, $sComputerName) Return SetError(@error, 0, $iSSM) EndFunc i can't use func. can you help me ? Link to comment Share on other sites More sharing options...
water Posted August 22, 2013 Share Posted August 22, 2013 You need to give us more information. Do you get any errors? What is the return value, @error of _Service_SetStartType My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
bordomavi Posted August 22, 2013 Author Share Posted August 22, 2013 ERROR: syntax error _Service_SetStartType Link to comment Share on other sites More sharing options...
water Posted August 22, 2013 Share Posted August 22, 2013 Can you please post the whole output from the SciTe output pane? The error information shows exactly where the error is. My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
bordomavi Posted August 22, 2013 Author Share Posted August 22, 2013 Can you please post the whole output from the SciTe output pane? The error information shows exactly where the error is. i downloaded Services.au3 and SecurityEx.au3 and i write only this to editor #include <Services.au3> _Service_SetStartType _Service_Stop Func _Service_Stop("Service1", $sComputerName = "") Local $iSSM = _Service_SetStartType($sServiceName, $SERVICE_DISABLED, $sComputerName) Return SetError(@error, 0, $iSSM) EndFunc Link to comment Share on other sites More sharing options...
water Posted August 22, 2013 Share Posted August 22, 2013 When I try your script I get a "Duplicate function name." error message. Looks like the function is already defined in the UDF. My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
water Posted August 22, 2013 Share Posted August 22, 2013 To disable a service you need something like this: #RequireAdmin #include <Services.au3> $iReturnValue = _Service_Change("SensrSvc", $SERVICE_NO_CHANGE, $SERVICE_DISABLED) ConsoleWrite($iReturnValue & "-" & @error & @CRLF) My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
bordomavi Posted August 22, 2013 Author Share Posted August 22, 2013 When I try your script I get a "Duplicate function name." error message. Looks like the function is already defined in the UDF. i want just stop service and change startup options. Link to comment Share on other sites More sharing options...
water Posted August 22, 2013 Share Posted August 22, 2013 Then try to stop and modify service "SensrSvc" as an example: #RequireAdmin #include <Services.au3> $sServiceName = "SensrSvc" $iReturnValue = _Service_Stop($sServiceName) ConsoleWrite($iReturnValue & "-" & @error & @CRLF) $iReturnValue = _Service_Change($sServiceName, $SERVICE_NO_CHANGE, $SERVICE_DISABLED) ConsoleWrite($iReturnValue & "-" & @error & @CRLF) My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
bordomavi Posted August 22, 2013 Author Share Posted August 22, 2013 it change startup. and i want stop service. and enable startup. Link to comment Share on other sites More sharing options...
water Posted August 22, 2013 Share Posted August 22, 2013 This shouldn't be too hard for you to do it yourself. Given the example code I've already posted. My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
bordomavi Posted August 22, 2013 Author Share Posted August 22, 2013 yes but you write _Service_Stop but it does not stop servicei it chagnes startup Link to comment Share on other sites More sharing options...
water Posted August 22, 2013 Share Posted August 22, 2013 (edited) Then check the return value of _Service_Stop and only proceed if it was successful. #RequireAdmin #include <Services.au3> $sServiceName = "SensrSvc" $iReturnValue = _Service_Stop($sServiceName) ConsoleWrite($iReturnValue & "-" & @error & @CRLF) If $iReturnValue = 1 Then $iReturnValue = _Service_Change($sServiceName, $SERVICE_NO_CHANGE, $SERVICE_DISABLED) ConsoleWrite($iReturnValue & "-" & @error & @CRLF) EndIf Edited August 22, 2013 by water My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
bordomavi Posted August 22, 2013 Author Share Posted August 22, 2013 Then check the return value of _Service_Stop and only proceed if it was successful. #RequireAdmin #include <Services.au3> $sServiceName = "SensrSvc" $iReturnValue = _Service_Stop($sServiceName) ConsoleWrite($iReturnValue & "-" & @error & @CRLF) If $iReturnValue = 1 Then $iReturnValue = _Service_Change($sServiceName, $SERVICE_NO_CHANGE, $SERVICE_DISABLED) ConsoleWrite($iReturnValue & "-" & @error & @CRLF) EndIf and last question. how can i start service and chang startup for automatic Link to comment Share on other sites More sharing options...
0xdefea7 Posted August 23, 2013 Share Posted August 23, 2013 _Service_SetType _Service_Start Link to comment Share on other sites More sharing options...
bordomavi Posted August 23, 2013 Author Share Posted August 23, 2013 _Service_SetType _Service_Start #RequireAdmin #include <Services.au3> $sServiceName = "TeamViewer8" $iReturnValue = _Service_Stop($sServiceName) ConsoleWrite($iReturnValue & "-" & @error & @CRLF) If $iReturnValue = 1 Then $iReturnValue = _Service_Change($sServiceName, $SERVICE_NO_CHANGE, $SERVICE_DISABLED) ConsoleWrite($iReturnValue & "-" & @error & @CRLF) EndIf the service's startup type not change. it is disabled. i want change it to automatic. Link to comment Share on other sites More sharing options...
water Posted August 23, 2013 Share Posted August 23, 2013 Now I think it is time you try something yourself! Open the UDF, locate function _Service_Change and read the function header. Has all the needed information. Change $SERVICE_DISABLED to the value needed. My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki 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