• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 434
  • Last Modified:

Get a list of remote services - vb.net / .net

Hi,

Is there a way to get a list of all installed services (both disabled and enabled) on a remote computer using .net?


Thank you!
0
nahumba
Asked:
nahumba
  • 3
  • 2
1 Solution
 
weellioCommented:
this writes output to a cvs file, but you can change the output to whatever
you can use vbs or vb,net, or whatever for these scripts,.


strComputer = "." 'pick a computer or setup in some array
Const ForAppending = 8
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objLogFile = objFSO.OpenTextFile("c:\scripts\service_list.csv", _
    ForAppending, True)

objLogFile.Write _
    ("System Name,Service Name,Service Type,Service State, Exit " _
        & "Code,Process ID,Can Be Paused,Can Be Stopped,Caption," _
        & "Description,Can Interact with Desktop,Display Name,Error " _
        & "Control, Executable Path Name,Service Started," _
        & "Start Mode,Account Name ")
objLogFile.Writeline

Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colListOfServices = objWMIService.ExecQuery _
        ("Select * from Win32_Service")

For Each objService in colListOfServices
    objLogFile.Write(objService.SystemName) & ","
    objLogFile.Write(objService.Name) & ","
    objLogFile.Write(objService.ServiceType) & ","
    objLogFile.Write(objService.State) & ","
    objLogFile.Write(objService.ExitCode) & ","
    objLogFile.Write(objService.ProcessID) & ","
    objLogFile.Write(objService.AcceptPause) & ","
    objLogFile.Write(objService.AcceptStop) & ","
    objLogFile.Write(objService.Caption) & ","
    objLogFile.Write(objService.Description) & ","
    objLogFile.Write(objService.DesktopInteract) & ","
    objLogFile.Write(objService.DisplayName) & ","
    objLogFile.Write(objService.ErrorControl) & ","
    objLogFile.Write(objService.PathName) & ","
    objLogFile.Write(objService.Started) & ","
    objLogFile.Write(objService.StartMode) & ","
    objLogFile.Write(objService.StartName) & ","
    objLogFile.writeline
Next
objLogFile.Close
0
 
nahumbaAuthor Commented:
Hi,
Thanks, I know this can be done with WMI, but I was wondering if there's a way to do this with .NET
0
 
weellioCommented:
you mena the openscmanager is what you are looking for?
you want to make api calls?

http://msdn2.microsoft.com/en-us/library/ms685942.aspx microsoft details

http://www.go4expert.com/forums/showthread.php?t=182 step by step instructions
0
 
nahumbaAuthor Commented:
Hi weellio, well after looking at the links you've posted here, I think I'll do this using WMI :-)

Seems much more simplier for my specific needs.



Thank you!
0
 
weellioCommented:
it always is.  vbs and wmi are wonderful..  :)
take a lok at powershell... it even gets easier, once you learn the lingo
0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now