|
-
Apr 18th, 2005, 01:45 PM
#1
Thread Starter
New Member
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:
' I made up this IsInstalled property of coarse just to show you what I need.
Sub cmdInstallService_Click()
If NTService.IsInstalled = False Then
NTService.Install
End If
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
-
Apr 18th, 2005, 02:04 PM
#2
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:
Set ServiceSet = GetObject("winmgmts:{impersonationLevel=impersonate}").InstancesOf("Win32_Service")
For each Service in ServiceSet
MsgBox Service.Description
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 Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API 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 
-
Apr 18th, 2005, 02:08 PM
#3
Frenzied Member
Re: A still unanswered NT Service question!!!
 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:
' I made up this IsInstalled property of coarse just to show you what I need.
Sub cmdInstallService_Click()
If NTService.IsInstalled = False Then
NTService.Install
End If
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..
-
Apr 18th, 2005, 02:11 PM
#4
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?
-
Apr 18th, 2005, 02:14 PM
#5
Frenzied Member
Re: A still unanswered NT Service question!!!
 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:
Set ServiceSet = GetObject("winmgmts:{impersonationLevel=impersonate}").InstancesOf("Win32_Service")
For each Service in ServiceSet
MsgBox Service.Description
Next
Wow.. never knew it's that easy... 
VB Code:
Set ServiceSet = GetObject("winmgmts:{impersonationLevel=impersonate}").InstancesOf("Win32_Service")
For Each Service In ServiceSet
Debug.Print Service.Name, Service.DisplayName, Service.Description
Next
virtualblender forget about my suggestion..
-
Apr 18th, 2005, 02:14 PM
#6
Re: A still unanswered NT Service question!!!
Here you go.
VB Code:
Option Explicit
'Add a reference to MS WMI Scripting V1.2 Library
Private Sub Command1_Click()
Dim ServiceSet As Object
Dim Service As Object
Set ServiceSet = GetObject("winmgmts:{impersonationLevel=impersonate}").InstancesOf("Win32_Service")
For Each Service In ServiceSet
MsgBox Service.Name & " - " & Service.Description
Next
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 Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API 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 
-
Apr 18th, 2005, 02:19 PM
#7
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:
Option Explicit
'Add a reference to MS WMI Scripting V1.2 Library
Private Sub Command1_Click()
Dim ServiceSet As Object
Dim Service As Object
'Set ServiceSet = GetObject("winmgmts:{impersonationLevel=impersonate}").InstancesOf("Win32_Service")
Set ServiceSet = GetObject("winmgmts:{impersonationLevel=impersonate}").ExecQuery("select * from Win32_Service where name = 'Alerter'")
For Each Service In ServiceSet
MsgBox Service.Name & " - " & Service.Description
Next
End Sub
 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 Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API 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 
-
Apr 18th, 2005, 02:57 PM
#8
Thread Starter
New Member
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
-
Apr 18th, 2005, 03:16 PM
#9
Re: A still unanswered NT Service question!!! [RESOLVED]
 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 Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API 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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|