technical architecture.

Tag: services

Maxscript: Checking a remote Service’s Status

by on Aug.11, 2008, under .net, maxscript

here’s a little snippet to check the status of a service on a remote server. used as part of a little farm management utility that I’m updating to run with the 64bit stuff and experimenting with the net framework.

fn checkService ServiceName server =
    dotnet.loadassembly "System.ServiceProcess"
    sc = dotNetObject "System.ServiceProcess.ServiceController"
    if (server == "") do server = "." -- if no server is supplied, run the check on the local machine
    sc.Machinename = server
    try(scServices = sc.GetServices(server))catch(return "Timed Out")
    for scTemp in scServices do
        if (scTemp.ServiceName as string == ServiceName) then
            --print ( ServiceName + " - " + server + " - " +scTemp.Status.toString() )
            return scTemp.Status.ToString()
    return "Service Not found"

Thanks Chris Evans for the maxscript syntax highlighting!

2 Comments :, , more...

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!