Results 1 to 9 of 9

Thread: A still unanswered NT Service question!!! [RESOLVED]

  1. #1

    Thread Starter
    New Member
    Join Date
    Apr 2005
    Posts
    9

    Resolved A still unanswered NT Service question!!! [RESOLVED]

    I searched the whole web. And searched all threads concerning NT Service in this forum and I found the exact same question that I'm asking myself and you guys.

    Since nobody answered the other thread, I was hoping that maybe now the answer could come up. Tks in advance, here it goes:

    How can I tell wheter a service is already installed or not?

    Something like this:
    VB Code:
    1. ' I made up this IsInstalled property of coarse just to show you what I need.
    2.  
    3. Sub cmdInstallService_Click()
    4.  
    5.      If NTService.IsInstalled = False Then
    6.           NTService.Install
    7.      End If
    8.  
    9. End Sub
    I need this because the user that is viewing my vb application wants to know wheter it is installed or not. If not, he clicks the button install and ok! I can't make the user go to Settings -> Control Panel and look for the service... I must be able to tell the user this information!

    Tks
    Last edited by virtualblender; Apr 18th, 2005 at 02:58 PM. Reason: Question resolved

  2. #2
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: A still unanswered NT Service question!!!

    Welcome to the Forums.

    You can use WMI reference in VB6 to list all services installed on a system.

    VB Code:
    1. Set ServiceSet = GetObject("winmgmts:{impersonationLevel=impersonate}").InstancesOf("Win32_Service")
    2.  
    3. For each Service in ServiceSet
    4.     MsgBox Service.Description
    5. Next
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  3. #3
    Frenzied Member moinkhan's Avatar
    Join Date
    Jun 2000
    Location
    Karachi, Pakistan
    Posts
    2,011

    Re: A still unanswered NT Service question!!!

    Quote Originally Posted by virtualblender
    I searched the whole web. And searched all threads concerning NT Service in this forum and I found the exact same question that I'm asking myself and you guys.

    Since nobody answered the other thread, I was hoping that maybe now the answer could come up. Tks in advance, here it goes:

    How can I tell wheter a service is already installed or not?

    Something like this:
    VB Code:
    1. ' I made up this IsInstalled property of coarse just to show you what I need.
    2.  
    3. Sub cmdInstallService_Click()
    4.  
    5.      If NTService.IsInstalled = False Then
    6.           NTService.Install
    7.      End If
    8.  
    9. End Sub
    I need this because the user that is viewing my vb application wants to know wheter it is installed or not. If not, he clicks the button install and ok! I can't make the user go to Settings -> Control Panel and look for the service... I must be able to tell the user this information!

    Tks

    Well.. if you look into registry at HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services all the child nodes which which have the Type value set to >=10 (Hex) is a service....

    I am not on VB machine... otherwise i would have enumerated the keys for u..

  4. #4
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: A still unanswered NT Service question!!!

    RobDog888: I just tried this and it doesn't know what ServiceSet is. How do you declare that?

  5. #5
    Frenzied Member moinkhan's Avatar
    Join Date
    Jun 2000
    Location
    Karachi, Pakistan
    Posts
    2,011

    Re: A still unanswered NT Service question!!!

    Quote Originally Posted by RobDog888
    Welcome to the Forums.

    You can use WMI reference in VB6 to list all services installed on a system.

    VB Code:
    1. Set ServiceSet = GetObject("winmgmts:{impersonationLevel=impersonate}").InstancesOf("Win32_Service")
    2.  
    3. For each Service in ServiceSet
    4.     MsgBox Service.Description
    5. Next


    Wow.. never knew it's that easy...

    VB Code:
    1. Set ServiceSet = GetObject("winmgmts:{impersonationLevel=impersonate}").InstancesOf("Win32_Service")
    2.  
    3. For Each Service In ServiceSet
    4.     Debug.Print Service.Name, Service.DisplayName, Service.Description
    5. Next

    virtualblender forget about my suggestion..

  6. #6
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: A still unanswered NT Service question!!!

    Here you go.
    VB Code:
    1. Option Explicit
    2. 'Add a reference to MS WMI Scripting V1.2 Library
    3. Private Sub Command1_Click()
    4.     Dim ServiceSet As Object
    5.     Dim Service As Object
    6.     Set ServiceSet = GetObject("winmgmts:{impersonationLevel=impersonate}").InstancesOf("Win32_Service")
    7.     For Each Service In ServiceSet
    8.         MsgBox Service.Name & " - " & Service.Description
    9.     Next
    10. End Sub
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  7. #7
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: A still unanswered NT Service question!!!

    You can also execute a query against the database passing criteria for a particular service instead
    of enumerating them.

    VB Code:
    1. Option Explicit
    2. 'Add a reference to MS WMI Scripting V1.2 Library
    3. Private Sub Command1_Click()
    4.     Dim ServiceSet As Object
    5.     Dim Service As Object
    6.     'Set ServiceSet = GetObject("winmgmts:{impersonationLevel=impersonate}").InstancesOf("Win32_Service")
    7.     Set ServiceSet = GetObject("winmgmts:{impersonationLevel=impersonate}").ExecQuery("select * from Win32_Service where name = 'Alerter'")
    8.     For Each Service In ServiceSet
    9.         MsgBox Service.Name & " - " & Service.Description
    10.     Next
    11. End Sub
    Quote Originally Posted by moinkhan
    Wow.. never knew it's that easy...
    Neither did I until I learned about the power of WMI.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  8. #8

    Thread Starter
    New Member
    Join Date
    Apr 2005
    Posts
    9

    Thumbs up Re: A still unanswered NT Service question!!!

    Omg you guys are too fast! I thought of checking the forum only tomorrow but hey cool!

    So tks for the welcome (I forgot to mention it's my first post ^^)
    and of coarse... tks for the answer which worked perfectly. I'm using the query one that you mentioned

    Tksss

  9. #9
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: A still unanswered NT Service question!!! [RESOLVED]

    Quote Originally Posted by virtualblender
    Omg you guys are too fast! I thought of checking the forum only tomorrow but hey cool!
    I think you will find that VB Forums is "The" best forum around. Usually you can get a reply within minutes, depending
    on the time of day. I'm glad you didnt wait for tomorrow!

    We are all glad to help and always happy to have new members.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width