Check the status of a remote server's Service


/ Published in: Maxscript
Save to your folder(s)



Copy this code and paste it in your HTML
  1. fn checkService ServiceName server =
  2. (
  3. dotnet.loadassembly "System.ServiceProcess"
  4. sc = dotNetObject "System.ServiceProcess.ServiceController"
  5. if (server == "") do server = "." -- if no server is supplied, run the check on the local machine
  6. sc.Machinename = server
  7. try(scServices = sc.GetServices(server))catch(return "Timed Out")
  8. for scTemp in scServices do
  9. (
  10. if (scTemp.ServiceName as string == ServiceName) then
  11. (
  12. --print ( ServiceName + " - " + server + " - " +scTemp.Status.toString() )
  13. return scTemp.Status.ToString()
  14. )
  15. )
  16. return "Service Not found"
  17. )

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.