list computer services


/ Published in: Visual Basic
Save to your folder(s)



Copy this code and paste it in your HTML
  1. set shell = WScript.CreateObject("WScript.Shell")
  2. resultPath = "c:\Scripts\Resultados\Servicios.txt"
  3.  
  4.  
  5. Set ComputerObj = GetObject("WinNT://" & shell.ExpandEnvironmentStrings("%ComputerName%"))
  6. ComputerObj.Filter = Array("Service")
  7. Dim fso, tf
  8. Set fso = CreateObject("Scripting.FileSystemObject")
  9. Set tf = fso.CreateTextFile(resultPath, True)
  10. ' Escribir una l�­nea con un car�¡cter nueva l�­nea.
  11. For Each Service in ComputerObj
  12.  
  13. If Service.Name = "aspnet_state" or Service.Name = "OSearch" or Service.Name = "MSSQLSERVER" or Service.Name = "MSSQLServerOLAPService" or Service.Name = "MsDtsServer100" or Service.Name = "ReportServer" or Service.Name = "SPAdmin" or Service.Name = "SPSearch" or Service.Name = "SPTimerV3" or Service.Name = "SPTrace" or Service.Name = "SPWriter" Then
  14.  
  15.  
  16. tf.WriteLine( VbCrLf & "--------------------------------------------------" & VbCrLf )
  17.  
  18. tf.WriteLine("Nombre Real Servicio: " & Service.Name)
  19. tf.WriteLine("Nombre de Servicio: " & Service.Displayname)
  20. tf.WriteLine("Ruta del Servicio: " & Service.Path)
  21.  
  22. Dim estado,s
  23. s=Service.status
  24. Select Case s
  25. Case 1
  26. estado = "Detenido"
  27. Case 2
  28. estado = "Iniciando"
  29. Case 3
  30. estado = "Deteniendo"
  31. Case 4
  32. estado = "Iniciado"
  33. Case 5
  34. estado = "Continuando"
  35. Case 6
  36. estado = "Pausando"
  37. Case 7
  38. estado = "Pausado"
  39. End Select
  40.  
  41.  
  42. tf.WriteLine("Estado del Servicio: " & estado)
  43. tf.WriteLine("Cuenta del Servicio: " & Service.ServiceAccountName)
  44.  
  45.  
  46.  
  47.  
  48. end If
  49. Next
  50.  
  51.  
  52. tf.WriteLine( VbCrLf & "--------------------------------------------------")
  53.  
  54. tf.Close
  55.  
  56.  
  57.  
  58. shell.Run "notepad " & resultPath

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.