Jump to content
khidotdn

Please check service code windows

Recommended Posts

khidotdn

I would like to help on code check windows service , shown on the button. If it is disabled , the button serive out Enable and click Enable , then it displays Disable. Enable Service is also always . Thank you for your help

Share this post


Link to post
Share on other sites
water

Welcome to AutoIt and the forum!
Can you please show us what you have tried so far?

  • Like 1

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-01-27 - Version 1.3.3.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites
JLogan3o13

@khidotdn, welcome to the forum. As water mentions, we try to adhere to the "teach a man to fish" motto. I do have the following snippet I use, however, that at least gets you started. You can change the $sService variable to the name of the service you're looking for.

$wbemFlagReturnImmediately = 0x10
$wbemFlagForwardOnly = 0x20
$sService = "Application Identity"

$oWMI = ObjGet("winmgmts:\\.\root\cimv2")
$oItems = $oWMI.ExecQuery("SELECT * FROM Win32_Service", "WQL", $wbemFlagReturnImmediately + $wbemFlagForwardOnly)

    If IsObj($oItems) Then
       For $oService In $oItems
           If $oService.DisplayName = $sService Then
               ConsoleWrite($oService.DisplayName & " | " & $oService.StartMode & @CRLF)
           EndIf
       Next
    EndIf

From here, I would suggest you take some time to read through the help file to create your GUI. Below is a simple framework that will get you started. I'll leave it to you to learn how to add your own button (look at GUICtrlCreateButton in the help file) and put the code together:

#include <GUIConstantsEx.au3>

    $hGUI = GUICreate("Test", 300, 300)
        GUISetState(@SW_SHOW)

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                Exit
        EndSwitch
    WEnd

Once you have done some reading, and tried some things out on your own, feel free to post your code here if you run into issues. We will do our best to assist.

  • Like 1

√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites
khidotdn
 
I just do Autoit apprentice , you can give me a code ? so I can study on that platform ? Thank you

Share this post


Link to post
Share on other sites
JLogan3o13

@khidotdn, simply put - no. This forum is not a place where you put in a request and someone barfs up the code for you. You have been given more than enough to begin. How about you begin showing some effort?

  • Like 1

√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

×