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 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - 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
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 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - 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
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 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - 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
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

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

    • santoshM
      By santoshM
      How can i exit from a procedure in auto
      Func test() if x=o then     return endif endFunc  
    • Valnurat
      By Valnurat
      Hi
      Small question.
      I trying to find all index in an array with value higher than 7.
      How can that be possible?
    • TrashBoat
      By TrashBoat
      Could someone help me create or give an idea of how to do a incrementing for loop that would do this: https://i.imgur.com/YFUt47H.gifv
      I'm having a hard time figuring it out :S
    • msd1994
      By msd1994
      I have a script that just adds some keyboard shortcuts for things like displaying the current song and artist, moving the window to the side so it won't pop up in my way, and play/pause, next song, previous song (these are the only 3 to still work since they don't need the window handle.)
      In some update recently, Spotify's window class swapped from "[CLASS:SpotifyMainWindow]" to "[CLASS:Chrome_WidgetWin_0]". Using the new class in my controls doesn't seem to work, I've tried getting the window handle from the process handle (_GetHwndFromPID($PID)) but that seems to fail as well.
      Does anybody have some idea of a way I could get this script working again?
       
      edit: seems like discord has the same window class name, so could be some issue with this? Still not sure of a way to solve the issue though, I added a function to get the handle of the active window and can just use that now, but it was able to find it on its own before on spotify startup or script startup which would be preferred.
       
      Thanks!
    • sumandevadiga
      By sumandevadiga
      Hello 
      I would like to Run Outlook macros from Autoit every 1 hour, below script unable to run macros.
      While 1 $Minute = Random(1,59,1) Do Sleep(1000) Until @Min = $Minute ; do whatever ; Since we want it to run randomly once an hour, we need to calculate how much time is left before the hour is up, and sleep that length of time. $s = ((60 - $Minute) * 60) * 1000 Sleep($s) $oOApp = ObjCreate("Outlook.Application") $oOApp.Run("SaveAttachments") ; Run Outlook Macros WEnd  
       
×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.