Services Info

Author Message
1RealTruth

  • Total Posts : 2
  • Scores: 0
  • Reward points : 0
  • Joined: 3/26/2009
  • Location: Cleveland Ohio
  • Status: offline
Services Info Sunday, June 21, 2009 1:18 PM (permalink)
0

With help from several people I was able to compile codes from various "Services" vbscripts to create a modified version.  The original retrieved the services from the local computer and displayed them on the screen.  I thought it was hard to read and not too organized.  But I have to give the original author credit because with my limited knowledge, it was more than I could have written by myself.  My new version pulls the original information as well as additional information about the services on the computer.  In addition to the additional information, it also asks you what computer you want to get the information from.  Then it creates a text file with the computer name or IP "example c:\mycomputer-ServicesInfo.txt".
 
<CODE>
 
'===================================================================================
' NAME: Services.vbs
' AUTHOR: Kevin D (1RealTruth) , Support
' DATE  : 1/27/2009
' Latest Revision 1-27-2009:  Added additional information, Start Mode, Start Name
'  and it sends the results to a text file with the computer name. It asks for
'  computer name or IP so it can pull the information from a remote computer.
'* Purpose:     display service information on a computer using WMI
'* Requires:    WMI to be installed on server specified
'* Revisions:   Initial development - 01/08/01, tonymu
'* Disclaimer:  This code is to be used for sample purposes only
'*              Microsoft does not guarantee its functionality
'***********************************************************************************
' Known Errors/Issues:
'   The following error will be returned if WMI is not installed
'        <path-to>\Services.vbs(23, 1) Microsoft VBScript runtime error:
'   ActiveX component can't create object: 'GetObject'
'
'   The following error will be returned if the servier is unavailable.
'   <path-to>\Services.vbs(27, 1) Microsoft VBScript runtime error:
'      The remote server machine does not exist or is unavailable: 'GetObject'
'===================================================================================
Option Explicit
Dim oArgs, strServerName, oServiceSet, oWshNetwork
Dim objShell, objFSO, objOutputFile, Service
strServerName = InputBox("What is the Server or IP?")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objOutputFile = objFSO.CreateTextFile("C:\" & strServerName & "-ServiceInfo.txt", 2, True)
objOutputFile.WriteLine("  Computer Name:  " & strServerName)
objOutputFile.WriteLine("Today's Date is:  " & Date)
objOutputFile.WriteLine("    The Time is:  " & Time)
Set oServiceSet = GetObject("winmgmts:{impersonationLevel=impersonate}!//" & strServerName & "/root/cimv2").InstancesOf("Win32_Service")
If strServerName = "LocalHost" Then
   Set oWshNetwork = WScript.CreateObject("WScript.Network")
   ObjOutputFile.WriteLine "Service Information retrieved from " & oWshNetwork.ComputerName
   Set oWshNetwork = Nothing
Else
   WScript.Echo "Service Information retrieved from " & strServerName
End If
WScript.Echo String(75, "_")
For Each Service in oServiceSet
 ObjOutputFile.WriteLine VbCrLf & _
 " --------------------- " & VbCrLf & _
 " Service Name:    " & Service.DisplayName  & VbCrLf & _
 " Short Name:      " & Service.Name  & VbCrLf & _
 " Current State:   " & Service.State & VbCrLf & _
 " Start Mode:      " & Service.StartMode & VbCrLf & _
 " Start Name:      " & Service.StartName & VbCrLf & _
 " " & VbCrLf & _
 "===> " & Service.Description & VbCrLf & _
 " " & VbCrLf & _
 " "
Next
WScript.Echo String(75, "_")
Set oServiceSet = Nothing
 
< CODE >
 
#1

    Online Bookmarks Sharing: Share/Bookmark

    Jump to:

    Current active users

    There are 0 members and 1 guests.

    Icon Legend and Permission

    • New Messages
    • No New Messages
    • Hot Topic w/ New Messages
    • Hot Topic w/o New Messages
    • Locked w/ New Messages
    • Locked w/o New Messages
    • Read Message
    • Post New Thread
    • Reply to message
    • Post New Poll
    • Submit Vote
    • Post reward post
    • Delete my own posts
    • Delete my own threads
    • Rate post

    2000-2012 ASPPlayground.NET Forum Version 3.9