Nunos Posted May 16, 2017 Share Posted May 16, 2017 Hello all LTNS, I have been away for a longtime and I must have forgotten what little I thought I knew about AutoIT. I am trying to make a script using Engine's services.udf that can see if a service exists and then select a case from a handful of choices and perform tasks based on that. Here is the link to Engines UDF https://www.autoitscript.com/forum/topic/81880-windows-services-udf/ and a link to the required au3's. https://www.autoitscript.com/forum/applications/core/interface/file/attachment.php?id=37024 https://www.autoitscript.com/forum/applications/core/interface/file/attachment.php?id=37025 So far I have made it through the If it Exists or not but the code can likely use some help and I made it to the Select Case Function I am writing but when I try to perform a service_stop on the service nothing happens. Please advise what I am doing wrong my code is below. I also would appreciate any pointers on improvements or easier ways to do it so I can progress my learning. #RequireAdmin #include "Services.au3" Local $sServiceName = "MpsSvc" Local $aiExist = _Service_Exists($sServiceName) Local $aiStatus = _Service_QueryStatus($sServiceName) If $aiExist = 1 Then ServiceStatus() ;MsgBox(0, "Service Exists", "The Service indeed does EXIST") If $aiExist = 0 Then MsgBox(0, "Service Exists", "The Service does NOT EXIST") Func ServiceStatus() MsgBox(0, "Checking", "Checking the status of the service.") Select Case $aiStatus[1] = $SERVICE_STOPPED MsgBox(0, "Service State", "The Windows Firewall Service is STOPPED.") Case $aiStatus[1] = $SERVICE_RUNNING _Service_Stop($sServiceName);MsgBox(0,"Service Status", "The Windows Firewall Service is RUNNING.") EndSelect EndFunc I am using the Windows FireWall Service to test with but the actual service will be a SQL Service. The commented out MsgBox inside of the Func ServiceStatus() does display when I remove the comments so I believe I am making it to there. Thank you in advance to anyone who can assist me. Link to comment Share on other sites More sharing options...
Nunos Posted May 17, 2017 Author Share Posted May 17, 2017 Checking in to see if anyone has any ideas what I am missing? 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