Jump to content
Valnurat

Check status of a service

Recommended Posts

Valnurat

How is it possible to check the status of a service?

I need to wait for a service to start before proceeding.


Yours sincerely

Kenneth.

Share this post


Link to post
Share on other sites
SadBunny
#include <array.au3>
#include <service.au3>

$aServices = _ServListInstalled()

_ArrayDisplay($aServices)
$spoolerStatus = _ServGetState("Spooler")
MsgBox(64, "Spooler service status", $spoolerStatus)

$appIDSvcStatus = _ServGetState("AppIDSvc")
MsgBox(64, "AppIDSvc service status", $appIDSvcStatus)

Do
    Sleep(1000)
    $myServiceStatus = _ServGetState("myServiceName")
Until $myServiceStatus = "Running"

MsgBox(64, "Yay!", "It's aliiiiiive!")

 


Roses are FF0000, violets are 0000FF... All my base are belong to you.

Share this post


Link to post
Share on other sites
water

In the wiki you can find a list of available UDFs: https://www.autoitscript.com/wiki/User_Defined_Functions


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-12-03 - Version 1.4.11.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - Wiki
iCal (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
Valnurat
1 hour ago, SadBunny said:
#include <array.au3>
#include <service.au3>

$aServices = _ServListInstalled()

_ArrayDisplay($aServices)
$spoolerStatus = _ServGetState("Spooler")
MsgBox(64, "Spooler service status", $spoolerStatus)

$appIDSvcStatus = _ServGetState("AppIDSvc")
MsgBox(64, "AppIDSvc service status", $appIDSvcStatus)

Do
    Sleep(1000)
    $myServiceStatus = _ServGetState("myServiceName")
Until $myServiceStatus = "Running"

MsgBox(64, "Yay!", "It's aliiiiiive!")

 

Where do I find the included service.au3?

I get an error: Can't open include file <service.au3>


Yours sincerely

Kenneth.

Share this post


Link to post
Share on other sites
SadBunny

Oh, sorry, I've had that UDF for ages. Check Water's link.


Roses are FF0000, violets are 0000FF... All my base are belong to you.

Share this post


Link to post
Share on other sites
water

Check my link above ;)


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-12-03 - Version 1.4.11.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - Wiki
iCal (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
Valnurat

The UDF by Engine?


Yours sincerely

Kenneth.

Share this post


Link to post
Share on other sites
water

Or:

Service (by arcker) - Build your own service with AutoIt code.
Windows Services (by engine) - Windows Services UDF.

Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-12-03 - Version 1.4.11.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - Wiki
iCal (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
Valnurat

Yes, I found them before, but they don't have the function calls in the exampel from SadBunny.


Yours sincerely

Kenneth.

Share this post


Link to post
Share on other sites
jguinch

Object way :

Local $sServiceName = "RemoteRegistry"
Local $oShell = ObjCreate("shell.application")

Do
    Sleep(100)
Until $oShell.IsServiceRunning($sServiceName)
MsgBox(0, "", "Service " & $sServiceName & " is running now")

 

Share this post


Link to post
Share on other sites
Valnurat

@jguinch - It worked.

Thank you.


Yours sincerely

Kenneth.

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

  • Similar Content

    • FordsFinest
      By FordsFinest
      Have come across an issue where I use the below code to select and then click an item. It works great on every computer but one, which happens to be my bosses computer (of course right lol).  So SelectItem works fine, but for some reason, the ClickItem command keeps clicking the item below the correct item (but only on this computer. I changed the command to controlsend instead, but i'd rather use the click option.. any ideas here?
       
      _GUICtrlTreeView_SelectItem($hWnd, $Array2[1]) _GUICtrlTreeView_ClickItem($hWnd, $Array2[1], "right")  
    • gahhon
      By gahhon
      So I had compiled my AutoIT script into executable file, I think like few weeks ago.
      But once after I compiled the script to executable file, I tested it and it work as expected.
      Somehow, I just now wanna try to execute it but failed

      Any idea what's is going on? Do I need to recompile the script again? @@
    • gahhon
      By gahhon
      I have a python script automate.py and I wanna run it via CMD.
      As I know to execute python via CMD is something like this
      $CMD = "Something python here" Run(@ComSpec & " /c " & $CMD) But how can I just open the 1 CMD and send multiple commands to the CMD based on the function called?
      For instance like:

      Launch CMD and send python then send import automate If google() function is called - send automate.google() to the CMD If yahoo() function is called - send automate.yahoo() to the CMD  I don't want to execute multiple CMD to call the automate functions. This is due to inside the python script have global variable to handle duplicate flag.
      So if I execute multiple CMD to call the functions, the global variable will be keep new as NULL. Which is not my expectation.
       
      Thanks
    • gahhon
      By gahhon
      I only found that AutoIt can actually execute the entire python script or execute the .exe (converted to .exe from .py)
      But what if I just want call the particular function? If that possible to do so?
      This is because python can't create fancy GUI like AutoIT does. So my plan is use AutoIT to have fancy GUI.
      Then each buttons will trigger specific function in the python script or .exe file.
      For instances:
      btnSum - trigger function in python script or .exe file (funcSum)
      btnMinus - trigger function in python script or .exe file (funcMinus)
       
      Thanks for advance information.
    • nacerbaaziz
      By nacerbaaziz
      Hello my friends
      Can we create a single context menu on more than one item?
      For example, a context menu includes standardized options on more than one control, such as buttons or check boxes
      to Create a context menu on one item am using this function
      GUICtrlCreateContextMenu ($ HWND)
      How to link it with more than one element please?
      or if we can't do that, please give me a solution
      so i tried to add an context menus to all the controls but the script will be long, for that if their are any solutions i hope to give it to me
      thanks in advanced
×