Noobis Posted February 23, 2024 Posted February 23, 2024 I am trying to make my first Autoit script to disable some services on several pc's. I found On page 5 the last post says script breaking changes and says to change something in the services.au3 but I am not sure what to change it to. I am recieving that same error. Here is my script appreciate anyone telling me what I need to change and would like to hear if I am doing anything wrong in my script below. #RequireAdmin #include "Services.au3" #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> Local $aServiceNames[5] ;$aServiceNames[0] = "bthserv" ;--> Bluetooth service $aServiceNames[0] = "Fax" ;--> Fax Service $aServiceNames[1] = "TermService" ;--> Remote Desktop Service $aServiceNames[2] = "RemoteRegistry" ;--> Remote Registry Service $aServiceNames[3] = "stisvc" ;--> Windows Image Acquisition $aServiceNames[4] = "wisvc" ;--> Windows Insider Service ; Loop through service names, calling _Service_setStartType to disable For $i = 0 To UBound($aServiceNames) - 1 _Service_SetStartType($aServiceNames, $SERVICE_DISABLED[$i]) Next ;_Service_SetStartType($sServiceName, $iStartType [, $sComputerName])
argumentum Posted February 23, 2024 Posted February 23, 2024 33 minutes ago, Noobis said: I am recieving that same error. Show the error. Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting.
Moderators SmOke_N Posted February 23, 2024 Moderators Posted February 23, 2024 I found the answer in this post Andreik and argumentum 2 Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.
Nine Posted February 23, 2024 Posted February 23, 2024 (edited) Here a very simple way to stop and disable a service : #RequireAdmin ; https://learn.microsoft.com/en-us/windows/win32/cimwin32prov/win32-service StopService("PhoneSvc") If @error Then ConsoleWrite("Not a service" & @CRLF) Func StopService($sService) Local $oHandler = ObjEvent("AutoIt.Error", WMIerror) Local $oWMI = ObjGet("winmgmts:\\" & @ComputerName & "\root\cimv2") Local $oService = $oWMI.Get("Win32_Service.Name='" & $sService & "'") If @error Then Return SetError(@error) $oService.StopService() $oService.ChangeStartMode("Disabled") EndFunc Func WMIerror($oError) EndFunc Edited February 23, 2024 by Nine “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy Interface Object based on Tag
Noobis Posted February 23, 2024 Author Posted February 23, 2024 10 hours ago, argumentum said: Show the error.
Andreik Posted February 23, 2024 Posted February 23, 2024 Just open Services.au3 and replace $RIGHTS_DELETE with $STANDARD_RIGHTS_DELETE.
Noobis Posted February 23, 2024 Author Posted February 23, 2024 41 minutes ago, Andreik said: Just open Services.au3 and replace $RIGHTS_DELETE with $STANDARD_RIGHTS_DELETE. This has made the script continue thank you. I have a new error am I using the wrong name for $SERVICE_DISABLED or is it something to do with the collection or array I tried to create at the start of the script? \Disable Services.au3" (18) : ==> Subscript used on non-accessible variable.: _Service_SetStartType($aServiceNames, $SERVICE_DISABLED[$i]) _Service_SetStartType($aServiceNames, $SERVICE_DISABLED^ ERROR
Noobis Posted February 23, 2024 Author Posted February 23, 2024 11 hours ago, SmOke_N said: I found the answer in this post yeah yeah hour super smart and can do everything better than everyone else except go read the last post that I referenced. Your expectation is that everyone coming in will know all the rules of posting in here and so when they don't measure up to your expectiations you try to virtue signal your greatness. No need to respond I will delete my account and go to a Python site to learn how to do this and use that going forward.
Andreik Posted February 23, 2024 Posted February 23, 2024 1 hour ago, Noobis said: This has made the script continue thank you. I have a new error am I using the wrong name for $SERVICE_DISABLED or is it something to do with the collection or array I tried to create at the start of the script? \Disable Services.au3" (18) : ==> Subscript used on non-accessible variable.: _Service_SetStartType($aServiceNames, $SERVICE_DISABLED[$i]) _Service_SetStartType($aServiceNames, $SERVICE_DISABLED^ ERROR This is your error and has nothing to do with UDF. Post the script that produce this error.
argumentum Posted February 23, 2024 Posted February 23, 2024 1 hour ago, Noobis said: No need to respond I will delete my account and go to a Python You're like, "Dad, i'm gonna tell Mom you're making fun of me". Take it like a grown up, not like a child. In this or any forum. You know that you asked a question based on something you did not share. Hard to answer. Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting.
Nine Posted February 23, 2024 Posted February 23, 2024 @Noobis I gave you a simple way to perform the task you were asking. At least you should have tried it...Anyway, have fun with python. “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy Interface Object based on Tag
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