Jump to content
khidotdn

Please check service code windows

Recommended Posts

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

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


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (2018-12-03 - Version 1.4.11.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2019-03-02 - Version 1.3.5.0) - Download - General Help & Support - Example Scripts - Wiki
Outlook Tools (2019-01-22 - Version 0.1.0.0) - Download - General Help & Support
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites

@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.

Share this post


Link to post
Share on other sites

@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?

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

×
×
  • Create New...