Click here to Skip to main content
15,913,758 members
Home / Discussions / System Admin
   

System Admin

 
Generalusing Remote desktop connection Pin
Hesham Amin20-Jul-04 2:48
Hesham Amin20-Jul-04 2:48 
GeneralRe: using Remote desktop connection Pin
Mike Dimmick21-Jul-04 1:35
Mike Dimmick21-Jul-04 1:35 
GeneralLookupAccountName Pin
MartinCC19-Jul-04 21:44
MartinCC19-Jul-04 21:44 
GeneralRe: LookupAccountName Pin
Mekong River9-Feb-06 20:31
Mekong River9-Feb-06 20:31 
GeneralChanging printers in the background. Pin
Jim Barrett19-Jul-04 4:46
Jim Barrett19-Jul-04 4:46 
GeneralRe: Changing printers in the background. Pin
Mekong River9-Feb-06 20:28
Mekong River9-Feb-06 20:28 
Generallist of the running services using NET Pin
Hesham Amin18-Jul-04 22:42
Hesham Amin18-Jul-04 22:42 
GeneralRe: list of the running services using NET Pin
Mekong River19-Jul-04 4:50
Mekong River19-Jul-04 4:50 
Do the followng procedure if you have visual studio .net 2002 or higher.

1. Create windows application in vb.net.
2. Place one ServiceController, one listbox and three command button on the form.
3. Rename the name of the listbox from ListBox1 to lstServices, rename the first button (command1) to btnLoad (this button will load all services it status (start or stop)), rename the second button (command2) to blnListStart (list only the name of the started service) and finally rename of the third button (command3) to btnListStop (list only the name of stopped services).
4. Write the following code for the btnLoad button:

    Private Sub btnLoad_Click(ByVal sender As System.Object, _<br />
    ByVal e As System.EventArgs) Handles btnLoad.Click<br />
<br />
        Dim services() As ServiceProcess.ServiceController<br />
        Dim i As Integer<br />
        Dim tmp, tmp2 As String<br />
        ' tmp variable store the service name.<br />
        ' tmp2 variable store the status of the service.<br />
<br />
        services = ServiceController1.GetServices<br />
        lstServices.Items.Clear() ' Clear the list box before<br />
        ' list the new service status.<br />
        For i = 0 To services.Length - 1<br />
            tmp = services(i).ServiceName ' Get the service name.<br />
            If CInt(services(i).Status) = 1 Then<br />
                tmp2 = "Status is stopped."<br />
            ElseIf CInt(services(i).Status) = 4 Then<br />
                tmp2 = "Status is started."<br />
            End If<br />
            lstServices.Items.Add(tmp & "--" & tmp2)<br />
        Next<br />
<br />
    End Sub


5. Write the following code for btnListStart button:

    Private Sub btnListStart_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnListStart.Click<br />
<br />
        ' List the start service only.<br />
        Dim services() As ServiceProcess.ServiceController<br />
        Dim i As Integer<br />
        Dim tmp, tmp2 As String<br />
<br />
        services = ServiceController1.GetServices<br />
        lstServices.Items.Clear()<br />
        For i = 0 To services.Length - 1<br />
            tmp = services(i).ServiceName<br />
            If CInt(services(i).Status) = 4 Then<br />
                tmp2 = "Status is started."<br />
                lstServices.Items.Add(tmp & "--" & tmp2)<br />
            End If<br />
        Next<br />
<br />
    End Sub


6. Write the following code for btnListStop button:

    Private Sub btnListStop_Click(ByVal sender As System.Object, _<br />
    ByVal e As System.EventArgs) Handles btnListStop.Click<br />
<br />
        ' List the stop service only.<br />
        Dim services() As ServiceProcess.ServiceController<br />
        Dim i As Integer<br />
        Dim tmp, tmp2 As String<br />
<br />
        services = ServiceController1.GetServices<br />
        lstServices.Items.Clear()<br />
        For i = 0 To services.Length - 1<br />
            tmp = services(i).ServiceName<br />
            If CInt(services(i).Status) = 1 Then<br />
                tmp2 = "Status is stopped."<br />
                lstServices.Items.Add(tmp & "--" & tmp2)<br />
            End If<br />
        Next<br />
<br />
    End Sub


I got the code and concept from:
Book Title: "Visual Basic .net programming"
Author: Harold Davis
ISBN: 81-7656-627-6
Chapter 10: Using Timers, EventLogs, and SerivceControllers
Section: Working with a ServiceController
Page: 244


Roath Kanel
APO-CEDC
Save Children Norway-Cambodia Office
GeneralRe: list of the running services using NET Pin
Hesham Amin19-Jul-04 7:06
Hesham Amin19-Jul-04 7:06 
GeneralRe: list of the running services using NET Pin
bigLasagne20-Jul-04 14:09
sussbigLasagne20-Jul-04 14:09 
GeneralRe: list of the running services using NET Pin
Mekong River21-Jul-04 4:11
Mekong River21-Jul-04 4:11 
GeneralDiskMngr functionality from an application. Pin
Thingfish4718-Jul-04 22:08
Thingfish4718-Jul-04 22:08 
GeneralShare calendar over peer to peer network Pin
Mekong River17-Jul-04 6:23
Mekong River17-Jul-04 6:23 
GeneralRe: Share calendar over peer to peer network Pin
Mike Dimmick18-Jul-04 8:33
Mike Dimmick18-Jul-04 8:33 
GeneralRe: Share calendar over peer to peer network Pin
Mekong River19-Jul-04 3:57
Mekong River19-Jul-04 3:57 
GeneralShare access database over the peer to peer network Pin
Mekong River17-Jul-04 5:35
Mekong River17-Jul-04 5:35 
GeneralRestore outlook express messages Pin
Mekong River15-Jul-04 13:10
Mekong River15-Jul-04 13:10 
GeneralRe: Restore outlook express messages Pin
Mike Dimmick15-Jul-04 20:42
Mike Dimmick15-Jul-04 20:42 
GeneralRe: Restore outlook express messages Pin
Mekong River17-Jul-04 3:59
Mekong River17-Jul-04 3:59 
GeneralRe: Restore outlook express messages Pin
Roger Wright17-Jul-04 4:24
professionalRoger Wright17-Jul-04 4:24 
GeneralRe: Restore outlook express messages Pin
Roger Wright15-Jul-04 20:43
professionalRoger Wright15-Jul-04 20:43 
GeneralCDROM not found in windows Pin
Mekong River15-Jul-04 12:38
Mekong River15-Jul-04 12:38 
GeneralAutomatic Updates - Please help Pin
david@mindplay.com15-Jul-04 6:44
david@mindplay.com15-Jul-04 6:44 
GeneralRe: Automatic Updates - Please help Pin
Steven Campbell15-Jul-04 7:16
Steven Campbell15-Jul-04 7:16 
GeneralRe: Automatic Updates - Please help Pin
Henry miller16-Jul-04 3:06
Henry miller16-Jul-04 3:06 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.