IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

VBScript Discussion :

Afficher image si condition respectée


Sujet :

VBScript

  1. #1
    Futur Membre du Club
    Profil pro
    Inscrit en
    Mars 2008
    Messages
    13
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mars 2008
    Messages : 13
    Points : 8
    Points
    8
    Par défaut Afficher image si condition respectée
    Bonjour,

    Je tente de faire un VBscript qui vérifie un certain nombre de service afin d'afficher la page Web dans le menu active destop du mon Pc (ça m'éviterai de me connecter sur X serveurs pour vérifier les services)

    je n'ai pas de problème pour vérifier si les services tournent ou pas mais j'amerai que se soit beau

    Pour l'instant mon script c'est :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    <SCRIPT LANGUAGE = VBScript>
    <!--
    strComputer = "serveurtest"
    Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=Impersonate}!\\" & strComputer & "\root\cimv2")
    Set colStoppedServices = objWMIService.ExecQuery _
        ("Select * From Win32_Service Where DisplayName = 'PCIA1")
    For Each objService in colStoppedServices
    document.write objService.DisplayName & " = " & objService.State      
    Next
    </SCRIPT>
    ce qui me donne :


    PCIA1 = Running

    J'aimerai qu'il m'affiche un petit rond vert si le service à pour état Running et Un rond rouge si il n'est pas en état Running.

    du genre :

    PCIA1 si il tourne et PCIA1 si il ne troune pas

    pouvez vous m'aider ?

  2. #2
    Expert confirmé
    Avatar de ced600
    Homme Profil pro
    Développeur .NET
    Inscrit en
    Août 2006
    Messages
    3 364
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 42
    Localisation : France

    Informations professionnelles :
    Activité : Développeur .NET

    Informations forums :
    Inscription : Août 2006
    Messages : 3 364
    Points : 4 061
    Points
    4 061
    Par défaut
    Je ne sais pas quelle sont tes conditions pour les OS, mais si tu peux mettre une machine sous linux tu devrais peut être changer d'orientation.
    Je m'explique :

    Ce que tu fais c'est de la supervision de service, de porgrame, de serveur.
    Un outil fonctionnant sous linux, super performant, et gratuit est disponible sur le net : Nagios.

    En plus je ne crois pas qu'il soit très compliqué à mettre en place, et il est bien plus complet que ce que tu feras. Et tu peux consuilté l'état d'un serveur, d'un service, ... via une page web.

    Edit : il existe des outils pour que nagios puisse superviser des serveurs MS, mais un certain nombre de fonctionnalité ne sont pas dev. -> on peut apparement créer des scripts pour rajouter certaine fonctionnalité.
    Pourquoi faire compliqué lorsque l'on peut faire encore plus compliqué.

  3. #3
    Membre averti
    Inscrit en
    Août 2007
    Messages
    302
    Détails du profil
    Informations personnelles :
    Âge : 57

    Informations forums :
    Inscription : Août 2007
    Messages : 302
    Points : 341
    Points
    341
    Par défaut
    Salut,

    sinon tu peux passer par un HTA...envoie nous ton script complet pour voir ce que l'on peut faire.

    A++
    Plus tu pédales moins vite, moins t'avances plus vite.

  4. #4
    Futur Membre du Club
    Profil pro
    Inscrit en
    Mars 2008
    Messages
    13
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mars 2008
    Messages : 13
    Points : 8
    Points
    8
    Par défaut
    Citation Envoyé par ced600 Voir le message
    Je ne sais pas quelle sont tes conditions pour les OS, mais si tu peux mettre une machine sous linux tu devrais peut être changer d'orientation.
    Je m'explique :

    Ce que tu fais c'est de la supervision de service, de porgrame, de serveur.
    Un outil fonctionnant sous linux, super performant, et gratuit est disponible sur le net : Nagios.

    En plus je ne crois pas qu'il soit très compliqué à mettre en place, et il est bien plus complet que ce que tu feras. Et tu peux consuilté l'état d'un serveur, d'un service, ... via une page web.

    Edit : il existe des outils pour que nagios puisse superviser des serveurs MS, mais un certain nombre de fonctionnalité ne sont pas dev. -> on peut apparement créer des scripts pour rajouter certaine fonctionnalité.
    désolé il n'est pas possible de passer sous linux une trentaine de serveurs

  5. #5
    Futur Membre du Club
    Profil pro
    Inscrit en
    Mars 2008
    Messages
    13
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mars 2008
    Messages : 13
    Points : 8
    Points
    8
    Par défaut
    Citation Envoyé par RadPAT Voir le message
    Salut,

    sinon tu peux passer par un HTA...envoie nous ton script complet pour voir ce que l'on peut faire.

    A++
    j'ai pris ton idée de passer par un HTA mais problème identique je ne sais pas comment récupérer un variable d'un VBscript vers le HTA

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
     
    <HTA:APPLICATION ID="HTA" />
    <HTML>
    <HEAD>
     
     
    </HEAD>
    <BODY>
    <SCRIPT LANGUAGE = VBScript>
    <!--
     
    strComputer = "srvoracle"
    Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=Impersonate}!\\" & strComputer & "\root\cimv2")
    Set colStoppedServices = objWMIService.ExecQuery _
        ("Select * From Win32_Service Where DisplayName = 'PCIA-EXP")
    For Each objService in colStoppedServices
    document.write objService.DisplayName & " = " & objService.State         
    Next
    </SCRIPT>
     
    <BODY>

  6. #6
    Modérateur
    Avatar de AlainTech
    Homme Profil pro
    Consultant informatique
    Inscrit en
    Mai 2005
    Messages
    4 235
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 70
    Localisation : Belgique

    Informations professionnelles :
    Activité : Consultant informatique
    Secteur : Finance

    Informations forums :
    Inscription : Mai 2005
    Messages : 4 235
    Points : 24 327
    Points
    24 327
    Par défaut
    Citation Envoyé par Yogui74 Voir le message
    désolé il n'est pas possible de passer sous linux une trentaine de serveurs
    Qui te parle de changer tes serveurs?
    Une machine Linux avec Nagios dessus peut te montrer l'état de tous tes serveurs de manière graphique ainsi que l'état de différents services avec, en prime, l'envoi de mails en cas d'alarme.
    N'oubliez pas de cliquer sur quand vous avez obtenu ou trouvé vous-même la réponse à votre question.
    Si vous trouvez seul, pensez à poster votre solution. Elle peut servir à d'autres!
    Pensez aussi à voter pour les réponses qui vous ont aidés.
    ------------
    Je dois beaucoup de mes connaissances à mes erreurs!

  7. #7
    Expert éminent sénior


    Profil pro
    Inscrit en
    Juin 2003
    Messages
    14 008
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2003
    Messages : 14 008
    Points : 20 038
    Points
    20 038
    Par défaut
    et en faisant un test sur ton status ... modifie la ligne :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
    document.write objService.DisplayName & " = " & objService.State
    par
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
     
     
    IF objService.State="Running" THEN
    	MonStatus   = "<img src=""http://www.developpez.net/forums/images/smilies/toine.gif"">"
    	else
    	MonStatus   = "<img src=""http://www.developpez.net/forums/images/smilies/evilred.gif"">"
    End if
     
    document.write objService.DisplayName & " = " & MonStatus

  8. #8
    Membre averti
    Inscrit en
    Août 2007
    Messages
    302
    Détails du profil
    Informations personnelles :
    Âge : 57

    Informations forums :
    Inscription : Août 2007
    Messages : 302
    Points : 341
    Points
    341
    Par défaut
    Salut,

    quand je te parlai HTA, je pensai plus à qque chose comme ca :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
     
    <html>
    <head>
    <title>ProcessMonitor.Hta</title>
    <HTA:APPLICATION
         ID="ProcessMonitor"
         APPLICATIONNAME="ProcessMonitor"
         SCROLL="no"
         SINGLEINSTANCE="yes"
         WINDOWSTATE="normal"
         CAPTION="yes"
    >
    </head>
    <style>
    BODY
    {
       background-color: buttonface;
       font-family: Helvetica;
       font-size: 10pt;
       margin-top: 10px;
       margin-left: 20px;
       margin-right: 20px;
       margin-bottom: 10px;
    }
    #ListView1		{
    					font-size: 11px;
    				}
    #ListView2		{
    					font-size: 11px;
    				}
     
    .button
    {
       font-family: Helvetica;
       font-size: 8pt;
    }
    </style>
     
    <SCRIPT Language="VBScript">
     
    Const ForReading = 1
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    Set objFile = objFSO.OpenTextFile("Computers.txt", ForReading)
     
    Sub Window_Onload
     
        ListView1.font = "arial"
        ListView1.View = 3
        ListView1.GridLines = True
        ListView1.ColumnHeaders.Add , , "Server Name", 130
     
        ListView2.font = "arial"
        ListView2.View = 3
        ListView2.GridLines = True
        ListView2.ColumnHeaders.Add , , "Name", 150
        ListView2.ColumnHeaders.Add , , "Status", 90
     
        strComputer = "."
        Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
        Set colItems = objWMIService.ExecQuery("Select * From Win32_DesktopMonitor")
        For Each objItem in colItems
            intHorizontal = objItem.ScreenWidth
            intVertical = objItem.ScreenHeight
        Next
     
        XPos = 450
        YPos = 410
     
        intLeft = (intHorizontal - XPos) / 2
        intTop = (intVertical - YPos) / 2
     
        self.ResizeTo Xpos,YPos
        window.moveTo intLeft, intTop
     
        Do Until objFile.AtEndOfStream
           strLine = objFile.ReadLine
           If strLine <> "" Then
              Set itmx = ListView1.ListItems.Add(, ,strLine)
           End If
        Loop
     
     
    End Sub
     
    Sub ListView1_ColumnClick(ColumnHeader)
    	With ListView1
    		.Sorted = False
    		.SortKey = ColumnHeader.Index - 1
    		If .SortOrder = 0 Then
    			.SortOrder = 1
    		Else
    			.SortOrder = 0
    		End If
    		.Sorted = True
    	End With
    End Sub
     
    Sub ListView1_Click
     
        strC = ListView1.SelectedItem.Text
        ListView2.ListItems.Clear()
     
        Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=Impersonate}!\\" & strC & "\root\cimv2")
        Set colServices = objWMIService.ExecQuery("Select * From Win32_Service")
        For Each objService in colServices
            Set itmY = ListView2.ListItems.Add(, ,objService.Name)
            itmY.SubItems(1) = objService.State
        Next
     
    End sub
     
    Sub ListView2_ColumnClick(ColumnHeader)
    	With ListView2
    		.Sorted = False
    		.SortKey = ColumnHeader.Index - 1
    		If .SortOrder = 0 Then
    			.SortOrder = 1
    		Else
    			.SortOrder = 0
    		End If
    		.Sorted = True
    	End With
    End Sub
     
    Sub Window_OnUnload
     
        Quitter
     
    End Sub
     
    Sub Quitter
     
        self.Close()
     
    End sub
     
    </SCRIPT>
     
    <body bgcolor="buttonface">
    <Big><Big><Big><ul><u>
    <Center>
    Service Monitor
    </Big></Big></Big></ul></u>
    </Center>
     
    <table WIDTH="100%" BORDER=1>
    <td valign="top" COLUMN=1>
     
    <td width="130" height="220" style="border: 1px solid #C0C0C0">
    <OBJECT ID="ListView1" WIDTH=130 HEIGHT=220 CLASSID="CLSID:BDD1F04B-858B-11D1-B16A-00C0F0283628">
    		        <PARAM NAME="SortKey" VALUE="0">
    		        <PARAM NAME="View" VALUE="3">
    		        <PARAM NAME="Arrange" VALUE="0">
    		        <PARAM NAME="LabelEdit" VALUE="1">
    		        <PARAM NAME="SortOrder" VALUE="0">
    		        <PARAM NAME="Sorted" VALUE="-1">
    		        <PARAM NAME="MultiSelect" VALUE="0">
    		        <PARAM NAME="LabelWrap" VALUE="-1">
    		        <PARAM NAME="HideSelection" VALUE="0">
    		        <PARAM NAME="HideColumnHeaders" VALUE="0">
    		        <PARAM NAME="OLEDragMode" VALUE="0">
    		        <PARAM NAME="OLEDropMode" VALUE="0">
    		        <PARAM NAME="AllowReorder" VALUE="-1">
    		        <PARAM NAME="Checkboxes" VALUE="0">
    		        <PARAM NAME="FlatScrollBar" VALUE="0">
    		        <PARAM NAME="FullRowSelect" VALUE="-1">
    		        <PARAM NAME="GridLines" VALUE="-1">
    		        <PARAM NAME="HotTracking" VALUE="0">
    		        <PARAM NAME="HoverSelection" VALUE="0">
    		        <PARAM NAME="PictureAlignment" VALUE="0">
    	                <PARAM NAME="TextBackground" VALUE="0">
                            <PARAM NAME="ForeColor" VALUE="-2147483640">
    	                <PARAM NAME="BackColor" VALUE="-2147483624">
    		        <PARAM NAME="BorderStyle" VALUE="0">
    		        <PARAM NAME="Appearance" VALUE="0">
    		        <PARAM NAME="MousePointer" VALUE="0">
    		        <PARAM NAME="Enabled" VALUE="1">
    		        <PARAM NAME="NumItems" VALUE="0">
    	   		<param name="OLEDragMode" value="0">
    			<param name="OLEDropMode" value="0">
    </OBJECT>
     
    <td width="240" height="220" style="border: 1px solid #C0C0C0">
    <OBJECT ID="ListView2" WIDTH=240 HEIGHT=220 CLASSID="CLSID:BDD1F04B-858B-11D1-B16A-00C0F0283628">
    		        <PARAM NAME="SortKey" VALUE="0">
    		        <PARAM NAME="View" VALUE="3">
    		        <PARAM NAME="Arrange" VALUE="0">
    		        <PARAM NAME="LabelEdit" VALUE="1">
    		        <PARAM NAME="SortOrder" VALUE="0">
    		        <PARAM NAME="Sorted" VALUE="-1">
    		        <PARAM NAME="MultiSelect" VALUE="0">
    		        <PARAM NAME="LabelWrap" VALUE="-1">
    		        <PARAM NAME="HideSelection" VALUE="0">
    		        <PARAM NAME="HideColumnHeaders" VALUE="0">
    		        <PARAM NAME="OLEDragMode" VALUE="0">
    		        <PARAM NAME="OLEDropMode" VALUE="0">
    		        <PARAM NAME="AllowReorder" VALUE="-1">
    		        <PARAM NAME="Checkboxes" VALUE="0">
    		        <PARAM NAME="FlatScrollBar" VALUE="0">
    		        <PARAM NAME="FullRowSelect" VALUE="-1">
    		        <PARAM NAME="GridLines" VALUE="-1">
    		        <PARAM NAME="HotTracking" VALUE="0">
    		        <PARAM NAME="HoverSelection" VALUE="0">
    		        <PARAM NAME="PictureAlignment" VALUE="0">
    	                <PARAM NAME="TextBackground" VALUE="0">
                            <PARAM NAME="ForeColor" VALUE="-2147483640">
    	                <PARAM NAME="BackColor" VALUE="-2147483624">
    		        <PARAM NAME="BorderStyle" VALUE="0">
    		        <PARAM NAME="Appearance" VALUE="0">
    		        <PARAM NAME="MousePointer" VALUE="0">
    		        <PARAM NAME="Enabled" VALUE="1">
    		        <PARAM NAME="NumItems" VALUE="0">
    	   		<param name="OLEDragMode" value="0">
    			<param name="OLEDropMode" value="0">
    </OBJECT>
     
    </td>
    </tr>
     
    <table WIDTH="100%" BORDER=1>
    <td VALIGN=TOP WIDTH="25%" COLSPAN=2>
    <table BORDER=0>
    </fieldset>
     
    <center>
    </table>
    <fieldset>
    <br>
    <input id=Quitbutton  class="button" type="button" value="   Quit   " name="Quitter_Button"  onClick="Quitter">
    </center>
    <br>
    </fieldset>
    </body>
    </html>
    C'est juste un exemple vite fait, ce sera à optimiser ou réagencer suivant tes besoins.
    NB tu dois créer dans la meme directory que le HTA un fichier Computers.Txt où sont rangées la liste des machines à monitorer avec une machine par ligne, comme ceci :

    Machine1
    Machine2
    .../...

    Je crois qu'il est possible de mettre des images dans une listeview ou des couleurs différentes suivant le statut, à vérifier.
    Sinon, après tu peux faire un click sur la colonne Status afin d'avoir un tri sur les différents statut.

    A++
    Plus tu pédales moins vite, moins t'avances plus vite.

  9. #9
    Futur Membre du Club
    Profil pro
    Inscrit en
    Mars 2008
    Messages
    13
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mars 2008
    Messages : 13
    Points : 8
    Points
    8
    Par défaut
    Citation Envoyé par AlainTech Voir le message
    Qui te parle de changer tes serveurs?
    Une machine Linux avec Nagios dessus peut te montrer l'état de tous tes serveurs de manière graphique ainsi que l'état de différents services avec, en prime, l'envoi de mails en cas d'alarme.
    Je n'avais pas lu de doc sur nagios... c'est maintenant fait effectivement ça pourrai mais j'aimerai aussi prévoir dans mon HTA (qui maintenant est adopté) ce qui me bloque pour Nagios c'est la partie cliente (il me semble avoir compris qu'il en faut une)

    la gestion des alertes est casiment déjà présente par les 10 appels que j'ai dans la minutes ou certains services tombent

  10. #10
    Futur Membre du Club
    Profil pro
    Inscrit en
    Mars 2008
    Messages
    13
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mars 2008
    Messages : 13
    Points : 8
    Points
    8
    Par défaut
    Citation Envoyé par RadPAT Voir le message
    Salut,

    quand je te parlai HTA, je pensai plus à qque chose comme ca :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
     
    <html>
    <head>
    <title>ProcessMonitor.Hta</title>
    <HTA:APPLICATION
         ID="ProcessMonitor"
         APPLICATIONNAME="ProcessMonitor"
         SCROLL="no"
         SINGLEINSTANCE="yes"
         WINDOWSTATE="normal"
         CAPTION="yes"
    >
    </head>
    <style>
    BODY
    {
       background-color: buttonface;
       font-family: Helvetica;
       font-size: 10pt;
       margin-top: 10px;
       margin-left: 20px;
       margin-right: 20px;
       margin-bottom: 10px;
    }
    #ListView1		{
    					font-size: 11px;
    				}
    #ListView2		{
    					font-size: 11px;
    				}
     
    .button
    {
       font-family: Helvetica;
       font-size: 8pt;
    }
    </style>
     
    <SCRIPT Language="VBScript">
     
    Const ForReading = 1
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    Set objFile = objFSO.OpenTextFile("Computers.txt", ForReading)
     
    Sub Window_Onload
     
        ListView1.font = "arial"
        ListView1.View = 3
        ListView1.GridLines = True
        ListView1.ColumnHeaders.Add , , "Server Name", 130
     
        ListView2.font = "arial"
        ListView2.View = 3
        ListView2.GridLines = True
        ListView2.ColumnHeaders.Add , , "Name", 150
        ListView2.ColumnHeaders.Add , , "Status", 90
     
        strComputer = "."
        Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
        Set colItems = objWMIService.ExecQuery("Select * From Win32_DesktopMonitor")
        For Each objItem in colItems
            intHorizontal = objItem.ScreenWidth
            intVertical = objItem.ScreenHeight
        Next
     
        XPos = 450
        YPos = 410
     
        intLeft = (intHorizontal - XPos) / 2
        intTop = (intVertical - YPos) / 2
     
        self.ResizeTo Xpos,YPos
        window.moveTo intLeft, intTop
     
        Do Until objFile.AtEndOfStream
           strLine = objFile.ReadLine
           If strLine <> "" Then
              Set itmx = ListView1.ListItems.Add(, ,strLine)
           End If
        Loop
     
     
    End Sub
     
    Sub ListView1_ColumnClick(ColumnHeader)
    	With ListView1
    		.Sorted = False
    		.SortKey = ColumnHeader.Index - 1
    		If .SortOrder = 0 Then
    			.SortOrder = 1
    		Else
    			.SortOrder = 0
    		End If
    		.Sorted = True
    	End With
    End Sub
     
    Sub ListView1_Click
     
        strC = ListView1.SelectedItem.Text
        ListView2.ListItems.Clear()
     
        Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=Impersonate}!\\" & strC & "\root\cimv2")
        Set colServices = objWMIService.ExecQuery("Select * From Win32_Service")
        For Each objService in colServices
            Set itmY = ListView2.ListItems.Add(, ,objService.Name)
            itmY.SubItems(1) = objService.State
        Next
     
    End sub
     
    Sub ListView2_ColumnClick(ColumnHeader)
    	With ListView2
    		.Sorted = False
    		.SortKey = ColumnHeader.Index - 1
    		If .SortOrder = 0 Then
    			.SortOrder = 1
    		Else
    			.SortOrder = 0
    		End If
    		.Sorted = True
    	End With
    End Sub
     
    Sub Window_OnUnload
     
        Quitter
     
    End Sub
     
    Sub Quitter
     
        self.Close()
     
    End sub
     
    </SCRIPT>
     
    <body bgcolor="buttonface">
    <Big><Big><Big><ul><u>
    <Center>
    Service Monitor
    </Big></Big></Big></ul></u>
    </Center>
     
    <table WIDTH="100%" BORDER=1>
    <td valign="top" COLUMN=1>
     
    <td width="130" height="220" style="border: 1px solid #C0C0C0">
    <OBJECT ID="ListView1" WIDTH=130 HEIGHT=220 CLASSID="CLSID:BDD1F04B-858B-11D1-B16A-00C0F0283628">
    		        <PARAM NAME="SortKey" VALUE="0">
    		        <PARAM NAME="View" VALUE="3">
    		        <PARAM NAME="Arrange" VALUE="0">
    		        <PARAM NAME="LabelEdit" VALUE="1">
    		        <PARAM NAME="SortOrder" VALUE="0">
    		        <PARAM NAME="Sorted" VALUE="-1">
    		        <PARAM NAME="MultiSelect" VALUE="0">
    		        <PARAM NAME="LabelWrap" VALUE="-1">
    		        <PARAM NAME="HideSelection" VALUE="0">
    		        <PARAM NAME="HideColumnHeaders" VALUE="0">
    		        <PARAM NAME="OLEDragMode" VALUE="0">
    		        <PARAM NAME="OLEDropMode" VALUE="0">
    		        <PARAM NAME="AllowReorder" VALUE="-1">
    		        <PARAM NAME="Checkboxes" VALUE="0">
    		        <PARAM NAME="FlatScrollBar" VALUE="0">
    		        <PARAM NAME="FullRowSelect" VALUE="-1">
    		        <PARAM NAME="GridLines" VALUE="-1">
    		        <PARAM NAME="HotTracking" VALUE="0">
    		        <PARAM NAME="HoverSelection" VALUE="0">
    		        <PARAM NAME="PictureAlignment" VALUE="0">
    	                <PARAM NAME="TextBackground" VALUE="0">
                            <PARAM NAME="ForeColor" VALUE="-2147483640">
    	                <PARAM NAME="BackColor" VALUE="-2147483624">
    		        <PARAM NAME="BorderStyle" VALUE="0">
    		        <PARAM NAME="Appearance" VALUE="0">
    		        <PARAM NAME="MousePointer" VALUE="0">
    		        <PARAM NAME="Enabled" VALUE="1">
    		        <PARAM NAME="NumItems" VALUE="0">
    	   		<param name="OLEDragMode" value="0">
    			<param name="OLEDropMode" value="0">
    </OBJECT>
     
    <td width="240" height="220" style="border: 1px solid #C0C0C0">
    <OBJECT ID="ListView2" WIDTH=240 HEIGHT=220 CLASSID="CLSID:BDD1F04B-858B-11D1-B16A-00C0F0283628">
    		        <PARAM NAME="SortKey" VALUE="0">
    		        <PARAM NAME="View" VALUE="3">
    		        <PARAM NAME="Arrange" VALUE="0">
    		        <PARAM NAME="LabelEdit" VALUE="1">
    		        <PARAM NAME="SortOrder" VALUE="0">
    		        <PARAM NAME="Sorted" VALUE="-1">
    		        <PARAM NAME="MultiSelect" VALUE="0">
    		        <PARAM NAME="LabelWrap" VALUE="-1">
    		        <PARAM NAME="HideSelection" VALUE="0">
    		        <PARAM NAME="HideColumnHeaders" VALUE="0">
    		        <PARAM NAME="OLEDragMode" VALUE="0">
    		        <PARAM NAME="OLEDropMode" VALUE="0">
    		        <PARAM NAME="AllowReorder" VALUE="-1">
    		        <PARAM NAME="Checkboxes" VALUE="0">
    		        <PARAM NAME="FlatScrollBar" VALUE="0">
    		        <PARAM NAME="FullRowSelect" VALUE="-1">
    		        <PARAM NAME="GridLines" VALUE="-1">
    		        <PARAM NAME="HotTracking" VALUE="0">
    		        <PARAM NAME="HoverSelection" VALUE="0">
    		        <PARAM NAME="PictureAlignment" VALUE="0">
    	                <PARAM NAME="TextBackground" VALUE="0">
                            <PARAM NAME="ForeColor" VALUE="-2147483640">
    	                <PARAM NAME="BackColor" VALUE="-2147483624">
    		        <PARAM NAME="BorderStyle" VALUE="0">
    		        <PARAM NAME="Appearance" VALUE="0">
    		        <PARAM NAME="MousePointer" VALUE="0">
    		        <PARAM NAME="Enabled" VALUE="1">
    		        <PARAM NAME="NumItems" VALUE="0">
    	   		<param name="OLEDragMode" value="0">
    			<param name="OLEDropMode" value="0">
    </OBJECT>
     
    </td>
    </tr>
     
    <table WIDTH="100%" BORDER=1>
    <td VALIGN=TOP WIDTH="25%" COLSPAN=2>
    <table BORDER=0>
    </fieldset>
     
    <center>
    </table>
    <fieldset>
    <br>
    <input id=Quitbutton  class="button" type="button" value="   Quit   " name="Quitter_Button"  onClick="Quitter">
    </center>
    <br>
    </fieldset>
    </body>
    </html>
    C'est juste un exemple vite fait, ce sera à optimiser ou réagencer suivant tes besoins.
    NB tu dois créer dans la meme directory que le HTA un fichier Computers.Txt où sont rangées la liste des machines à monitorer avec une machine par ligne, comme ceci :

    Machine1
    Machine2
    .../...

    Je crois qu'il est possible de mettre des images dans une listeview ou des couleurs différentes suivant le statut, à vérifier.
    Sinon, après tu peux faire un click sur la colonne Status afin d'avoir un tri sur les différents statut.

    A++

    Impressionnant ++ je ne pensai pas que le format HTA pouvait faire tant de chose mais en plus des états des servicesc'est surtout un petit code pour redémarrer et ou éteindre ces services qui m'intesse (il me faut éteindre des services d'un serveurs pour éteindre un seconde serveurs afin d'éviter une erreur dans les file d'attente PCIA)

    mais je suis vraiment sur le cul de ton script

  11. #11
    Futur Membre du Club
    Profil pro
    Inscrit en
    Mars 2008
    Messages
    13
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mars 2008
    Messages : 13
    Points : 8
    Points
    8
    Par défaut
    Citation Envoyé par bbil Voir le message
    et en faisant un test sur ton status ... modifie la ligne :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
    document.write objService.DisplayName & " = " & objService.State
    par
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
     
     
    IF objService.State="Running" THEN
    	MonStatus   = "<img src=""http://www.developpez.net/forums/images/smilies/toine.gif"">"
    	else
    	MonStatus   = "<img src=""http://www.developpez.net/forums/images/smilies/evilred.gif"">"
    End if
     
    document.write objService.DisplayName & " = " & MonStatus

    je prend cette solution pour mon problème qui été d'afficher une image celui une condition

    Mais merci à tous

  12. #12
    Membre averti
    Inscrit en
    Août 2007
    Messages
    302
    Détails du profil
    Informations personnelles :
    Âge : 57

    Informations forums :
    Inscription : Août 2007
    Messages : 302
    Points : 341
    Points
    341
    Par défaut
    Salut,

    merci pour tes encouragements, ca fait plaisir, par principe je ne réponds pas aux questions techniques par MP, je considère que le forum est là pour ça...
    Donc pour répondre à ta question oui c'est possible de n'afficher que les certains services pour certains PC, il faudrait que tu me donnes un exemple pour reconstruire un fichier computers.txt afin de s'appuyer dessus.
    Pour ta question est-il possible de démarrer ou d'arreter un service, regarde la nouvelle version que je te propose, il te suffit de cliquer dans la listview de droite. Pour que ca marche, il faut néanmoins que le service ne soit pas en statut "disable" (desactivé).

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
     
    <html>
    <head>
    <title>ServicesMonitor.Hta</title>
    <HTA:APPLICATION
         ID="ServicesMonitor"
         APPLICATIONNAME="ServicesMonitor"
         SCROLL="no"
         SINGLEINSTANCE="yes"
         WINDOWSTATE="normal"
         CAPTION="yes"
    >
    </head>
    <style>
    BODY
    {
       background-color: buttonface;
       font-family: Helvetica;
       font-size: 10pt;
       margin-top: 10px;
       margin-left: 20px;
       margin-right: 20px;
       margin-bottom: 10px;
    }
    #ListView1		{
    					font-size: 11px;
    				}
    #ListView2		{
    					font-size: 11px;
    				}
     
    .button
    {
       font-family: Helvetica;
       font-size: 8pt;
    }
    </style>
     
    <SCRIPT Language="VBScript">
     
    Const ForReading = 1
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    Set objFile = objFSO.OpenTextFile("Computers.txt", ForReading)
     
    Sub Window_Onload
     
        ListView1.font = "arial"
        ListView1.View = 3
        ListView1.GridLines = True
        ListView1.ColumnHeaders.Add , , "Server Name", 130
     
        ListView2.font = "arial"
        ListView2.View = 3
        ListView2.GridLines = True
        ListView2.ColumnHeaders.Add , , "DisplayName", 240
        ListView2.ColumnHeaders.Add , , "Name", 120
        ListView2.ColumnHeaders.Add , , "Status", 70
        ListView2.ColumnHeaders.Add , , "Start mode", 90
     
        strComputer = "."
        Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
        Set colItems = objWMIService.ExecQuery("Select * From Win32_DesktopMonitor")
        For Each objItem in colItems
            intHorizontal = objItem.ScreenWidth
            intVertical = objItem.ScreenHeight
        Next
     
        XPos = 750
        YPos = 410
     
        intLeft = (intHorizontal - XPos) / 2
        intTop = (intVertical - YPos) / 2
     
        self.ResizeTo Xpos,YPos
        window.moveTo intLeft, intTop
     
        Do Until objFile.AtEndOfStream
           strLine = objFile.ReadLine
           If strLine <> "" Then
              Set itmx = ListView1.ListItems.Add(, ,strLine)
           End If
        Loop
     
    End Sub
     
    Sub ListView1_ColumnClick(ColumnHeader)
    	With ListView1
    		.Sorted = False
    		.SortKey = ColumnHeader.Index - 1
    		If .SortOrder = 0 Then
    			.SortOrder = 1
    		Else
    			.SortOrder = 0
    		End If
    		.Sorted = True
    	End With
    End Sub
     
    Sub ListView1_Click
     
        strComputer = ListView1.SelectedItem.Text
        ListView2.ListItems.Clear()
     
        Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=Impersonate}!\\" & strComputer & "\root\cimv2")
        Set colServices = objWMIService.ExecQuery("Select * From Win32_Service")
        For Each objService in colServices
            Set itmY = ListView2.ListItems.Add(, ,objService.DisplayName)
            itmY.SubItems(1) = objService.Name
            itmY.SubItems(2) = objService.State
            itmY.SubItems(3) = objService.StartMode
        Next
     
    End sub
     
    Sub ListView2_ColumnClick(ColumnHeader)
    	With ListView2
    		.Sorted = False
    		.SortKey = ColumnHeader.Index - 1
    		If .SortOrder = 0 Then
    			.SortOrder = 1
    		Else
    			.SortOrder = 0
    		End If
    		.Sorted = True
    	End With
    End Sub
     
    Sub ListView2_Click
     
        If ListView2.SelectedItem.Text <> "" Then
           If ListView2.SelectedItem.SubItems(3) = "Disabled" Then
              Msgbox "Start mode is disabled, you have to enabled it before retry."
           Else
     
              strComputer = ListView1.SelectedItem.Text
              strService = ListView2.SelectedItem.SubItems(1)
              Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
              Set colListOfServices = objWMIService.ExecQuery ("Select * from Win32_Service Where Name ='" & strService & "'")
     
              If ListView2.SelectedItem.SubItems(2) = "Running" Then
                 Quest = Msgbox("If you confirm this operation, service '" & strService & "' will be stopped." & vbnewline & "Do you confirm this action?",vbsystemmodal+vbyesno+vbexclamation,"ATTENTION!!!")
                 if Quest = vbYes Then
                    For Each objService in colListOfServices
                        objService.StopService()
                    Next
                    ListView2.ListItems.Clear()
                    ListView1_Click
                 Else
                    Msgbox "Operation aborted."
                 End If
              Else
                 Quest = Msgbox("If you confirm this operation, service '" & strService & "' will be started." & vbnewline & "Do you confirm this action?",vbsystemmodal+vbyesno+vbexclamation,"ATTENTION!!!")
                 If Quest = vbYes Then
                    For Each objService in colListOfServices
                        objService.StartService()
                    Next
                    ListView2.ListItems.Clear()
                    ListView1_Click
                 Else
                    Msgbox "Operation aborted."
                 End If
              End If
           End If
        End If
     
    End Sub
     
    Sub Quitter
     
        self.Close()
     
    End sub
     
    </SCRIPT>
     
    <body bgcolor="buttonface">
    <Big><Big><Big><ul><u>
    <Center>
    Service Monitor
    </Big></Big></Big></ul></u>
    </Center>
     
    <table WIDTH="100%" BORDER=1>
    <td valign="top" COLUMN=1>
     
    <td width="130" height="220" style="border: 1px solid #C0C0C0">
    <OBJECT ID="ListView1" WIDTH=130 HEIGHT=220 CLASSID="CLSID:BDD1F04B-858B-11D1-B16A-00C0F0283628">
    		        <PARAM NAME="SortKey" VALUE="0">
    		        <PARAM NAME="View" VALUE="3">
    		        <PARAM NAME="Arrange" VALUE="0">
    		        <PARAM NAME="LabelEdit" VALUE="1">
    		        <PARAM NAME="SortOrder" VALUE="0">
    		        <PARAM NAME="Sorted" VALUE="-1">
    		        <PARAM NAME="MultiSelect" VALUE="0">
    		        <PARAM NAME="LabelWrap" VALUE="-1">
    		        <PARAM NAME="HideSelection" VALUE="0">
    		        <PARAM NAME="HideColumnHeaders" VALUE="0">
    		        <PARAM NAME="OLEDragMode" VALUE="0">
    		        <PARAM NAME="OLEDropMode" VALUE="0">
    		        <PARAM NAME="AllowReorder" VALUE="-1">
    		        <PARAM NAME="Checkboxes" VALUE="0">
    		        <PARAM NAME="FlatScrollBar" VALUE="0">
    		        <PARAM NAME="FullRowSelect" VALUE="-1">
    		        <PARAM NAME="GridLines" VALUE="-1">
    		        <PARAM NAME="HotTracking" VALUE="0">
    		        <PARAM NAME="HoverSelection" VALUE="0">
    		        <PARAM NAME="PictureAlignment" VALUE="0">
    	                <PARAM NAME="TextBackground" VALUE="0">
                            <PARAM NAME="ForeColor" VALUE="-2147483640">
    	                <PARAM NAME="BackColor" VALUE="-2147483624">
    		        <PARAM NAME="BorderStyle" VALUE="0">
    		        <PARAM NAME="Appearance" VALUE="0">
    		        <PARAM NAME="MousePointer" VALUE="0">
    		        <PARAM NAME="Enabled" VALUE="1">
    		        <PARAM NAME="NumItems" VALUE="0">
    	   		<param name="OLEDragMode" value="0">
    			<param name="OLEDropMode" value="0">
    </OBJECT>
     
    <td width="540" height="220" style="border: 1px solid #C0C0C0">
    <OBJECT ID="ListView2" WIDTH=540 HEIGHT=220 CLASSID="CLSID:BDD1F04B-858B-11D1-B16A-00C0F0283628">
    		        <PARAM NAME="SortKey" VALUE="0">
    		        <PARAM NAME="View" VALUE="3">
    		        <PARAM NAME="Arrange" VALUE="0">
    		        <PARAM NAME="LabelEdit" VALUE="1">
    		        <PARAM NAME="SortOrder" VALUE="0">
    		        <PARAM NAME="Sorted" VALUE="-1">
    		        <PARAM NAME="MultiSelect" VALUE="0">
    		        <PARAM NAME="LabelWrap" VALUE="-1">
    		        <PARAM NAME="HideSelection" VALUE="0">
    		        <PARAM NAME="HideColumnHeaders" VALUE="0">
    		        <PARAM NAME="OLEDragMode" VALUE="0">
    		        <PARAM NAME="OLEDropMode" VALUE="0">
    		        <PARAM NAME="AllowReorder" VALUE="-1">
    		        <PARAM NAME="Checkboxes" VALUE="0">
    		        <PARAM NAME="FlatScrollBar" VALUE="0">
    		        <PARAM NAME="FullRowSelect" VALUE="-1">
    		        <PARAM NAME="GridLines" VALUE="-1">
    		        <PARAM NAME="HotTracking" VALUE="0">
    		        <PARAM NAME="HoverSelection" VALUE="0">
    		        <PARAM NAME="PictureAlignment" VALUE="0">
    	                <PARAM NAME="TextBackground" VALUE="0">
                            <PARAM NAME="ForeColor" VALUE="-2147483640">
    	                <PARAM NAME="BackColor" VALUE="-2147483624">
    		        <PARAM NAME="BorderStyle" VALUE="0">
    		        <PARAM NAME="Appearance" VALUE="0">
    		        <PARAM NAME="MousePointer" VALUE="0">
    		        <PARAM NAME="Enabled" VALUE="1">
    		        <PARAM NAME="NumItems" VALUE="0">
    	   		<param name="OLEDragMode" value="0">
    			<param name="OLEDropMode" value="0">
    </OBJECT>
     
    </td>
    </tr>
     
    <table WIDTH="100%" BORDER=1>
    <td VALIGN=TOP WIDTH="25%" COLSPAN=2>
    <table BORDER=0>
    </fieldset>
     
    <center>
    </table>
    <fieldset>
    <br>
    <input id=Quitbutton  class="button" type="button" value="   Quit   " name="Quitter_Button"  onClick="Quitter">
    </center>
    <br>
    </fieldset>
    </body>
    </html>
    A++
    Plus tu pédales moins vite, moins t'avances plus vite.

  13. #13
    Futur Membre du Club
    Profil pro
    Inscrit en
    Mars 2008
    Messages
    13
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mars 2008
    Messages : 13
    Points : 8
    Points
    8
    Par défaut
    j'ai testé la nouvelle version encore bravo j'ai juste une erreur ligne 75

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
       window.moveTo intLeft, intTop
    Mais bon je l'ai mise en commentaire et plus de problème

    exemple de service pour deux serveurs :

    serveur Web

    PCIA-EXP-BAL2SIR-Bal2Xml
    PCIA-EXP-BAL2SIR-FormatSrc2FormatDest
    PCIA-EXP-CNET2ACTES
    PCIA-EXP-DAP2ACCUS-Bal2Xml
    PCIA-EXP-DAP2ACCUS
    PCIA-EXP-DAP2ACCUS-ERR

    Serveur SIHSGDB

    PCIA-EXP-DAP2DATA
    PCIA-EXP-ACCUS2DAP
    PCIA-EXP-ACCUS2DAP-ERR

    Et d'avance merci

  14. #14
    Membre averti
    Inscrit en
    Août 2007
    Messages
    302
    Détails du profil
    Informations personnelles :
    Âge : 57

    Informations forums :
    Inscription : Août 2007
    Messages : 302
    Points : 341
    Points
    341
    Par défaut
    Tiens :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
     
    <html>
    <head>
    <title>ServicesMonitor.Hta</title>
    <HTA:APPLICATION
         ID="ServicesMonitor"
         APPLICATIONNAME="ServicesMonitor"
         SCROLL="no"
         SINGLEINSTANCE="yes"
         WINDOWSTATE="normal"
         CAPTION="yes"
    >
    </head>
    <style>
    BODY
    {
       background-color: buttonface;
       font-family: Helvetica;
       font-size: 10pt;
       margin-top: 10px;
       margin-left: 20px;
       margin-right: 20px;
       margin-bottom: 10px;
    }
    #ListView1		{
    					font-size: 11px;
    				}
    #ListView2		{
    					font-size: 11px;
    				}
     
    .button
    {
       font-family: Helvetica;
       font-size: 8pt;
    }
    </style>
     
    <SCRIPT Language="VBScript">
     
    Const ForReading = 1
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    Set objFile = objFSO.OpenTextFile("Computers.txt", ForReading)
    Dim arrZne
     
    Sub Window_Onload
     
        ListView1.font = "arial"
        ListView1.View = 3
        ListView1.GridLines = True
        ListView1.ColumnHeaders.Add , , "Server Name", 130
     
        ListView2.font = "arial"
        ListView2.View = 3
        ListView2.GridLines = True
        ListView2.ColumnHeaders.Add , , "DisplayName", 240
        ListView2.ColumnHeaders.Add , , "Name", 120
        ListView2.ColumnHeaders.Add , , "Status", 70
        ListView2.ColumnHeaders.Add , , "Start mode", 90
     
        strComputer = "."
        Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
        Set colItems = objWMIService.ExecQuery("Select * From Win32_DesktopMonitor")
        For Each objItem in colItems
            intHorizontal = objItem.ScreenWidth
            intVertical = objItem.ScreenHeight
        Next
     
        XPos = 750
        YPos = 410
     
        I = 1
     
        intLeft = (intHorizontal - XPos) / 2
        intTop = (intVertical - YPos) / 2
     
        self.ResizeTo Xpos,YPos
        window.moveTo intLeft, intTop
     
        Do Until objFile.AtEndOfStream
           strLine = objFile.ReadLine
           If strLine <> "" Then
              VVal0 = Instr(strLine, ";")
              Set itmx = ListView1.ListItems.Add(, ,Left(strLine, VVal0 - 1))
              reDim arrZne(I)
              arrZne(I) = strLine
              I = I + 1
           End If
        Loop
     
    End Sub
     
    Sub ListView1_ColumnClick(ColumnHeader)
    	With ListView1
    		.Sorted = False
    		.SortKey = ColumnHeader.Index - 1
    		If .SortOrder = 0 Then
    			.SortOrder = 1
    		Else
    			.SortOrder = 0
    		End If
    		.Sorted = True
    	End With
    End Sub
     
    Sub ListView1_Click
     
        strComputer = ListView1.SelectedItem.Text
        ListView2.ListItems.Clear()
     
        For I = 0 To uBound(arrZne)
            If Instr(Ucase(arrZne(I)),Ucase(strComputer)) > 0 Then
               Zne = arrZne(I)
               Exit For
            End If
        Next
     
        Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=Impersonate}!\\" & strComputer & "\root\cimv2")
        Set colServices = objWMIService.ExecQuery("Select * From Win32_Service")
        For Each objService in colServices
            If Instr(Zne, objService.Name) > 0 Then
               Set itmY = ListView2.ListItems.Add(, ,objService.DisplayName)
               itmY.SubItems(1) = objService.Name
               itmY.SubItems(2) = objService.State
               itmY.SubItems(3) = objService.StartMode
            End If
        Next
     
    End sub
     
    Sub ListView2_ColumnClick(ColumnHeader)
    	With ListView2
    		.Sorted = False
    		.SortKey = ColumnHeader.Index - 1
    		If .SortOrder = 0 Then
    			.SortOrder = 1
    		Else
    			.SortOrder = 0
    		End If
    		.Sorted = True
    	End With
    End Sub
     
    Sub ListView2_Click
     
        If ListView2.SelectedItem.Text <> "" Then
           If ListView2.SelectedItem.SubItems(3) = "Disabled" Then
              Msgbox "Start mode is disabled, you have to enabled it before retry."
           Else
     
              strComputer = ListView1.SelectedItem.Text
              strService = ListView2.SelectedItem.SubItems(1)
              Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
              Set colListOfServices = objWMIService.ExecQuery ("Select * from Win32_Service Where Name ='" & strService & "'")
     
              If ListView2.SelectedItem.SubItems(2) = "Running" Then
                 Quest = Msgbox("If you confirm this operation, service '" & strService & "' will be stopped." & vbnewline & "Do you confirm this action?",vbsystemmodal+vbyesno+vbexclamation,"ATTENTION!!!")
                 if Quest = vbYes Then
                    For Each objService in colListOfServices
                        objService.StopService()
                    Next
                    ListView2.ListItems.Clear()
                    ListView1_Click
                 Else
                    Msgbox "Operation aborted."
                 End If
              Else
                 Quest = Msgbox("If you confirm this operation, service '" & strService & "' will be started." & vbnewline & "Do you confirm this action?",vbsystemmodal+vbyesno+vbexclamation,"ATTENTION!!!")
                 If Quest = vbYes Then
                    For Each objService in colListOfServices
                        objService.StartService()
                    Next
                    ListView2.ListItems.Clear()
                    ListView1_Click
                 Else
                    Msgbox "Operation aborted."
                 End If
              End If
           End If
        End If
     
    End Sub
     
    Sub Quitter
     
        self.Close()
     
    End sub
     
    </SCRIPT>
     
    <body bgcolor="buttonface">
    <Big><Big><Big><ul><u>
    <Center>
    Service Monitor
    </Big></Big></Big></ul></u>
    </Center>
     
    <table WIDTH="100%" BORDER=1>
    <td valign="top" COLUMN=1>
     
    <td width="130" height="220" style="border: 1px solid #C0C0C0">
    <OBJECT ID="ListView1" WIDTH=130 HEIGHT=220 CLASSID="CLSID:BDD1F04B-858B-11D1-B16A-00C0F0283628">
    		        <PARAM NAME="SortKey" VALUE="0">
    		        <PARAM NAME="View" VALUE="3">
    		        <PARAM NAME="Arrange" VALUE="0">
    		        <PARAM NAME="LabelEdit" VALUE="1">
    		        <PARAM NAME="SortOrder" VALUE="0">
    		        <PARAM NAME="Sorted" VALUE="-1">
    		        <PARAM NAME="MultiSelect" VALUE="0">
    		        <PARAM NAME="LabelWrap" VALUE="-1">
    		        <PARAM NAME="HideSelection" VALUE="0">
    		        <PARAM NAME="HideColumnHeaders" VALUE="0">
    		        <PARAM NAME="OLEDragMode" VALUE="0">
    		        <PARAM NAME="OLEDropMode" VALUE="0">
    		        <PARAM NAME="AllowReorder" VALUE="-1">
    		        <PARAM NAME="Checkboxes" VALUE="0">
    		        <PARAM NAME="FlatScrollBar" VALUE="0">
    		        <PARAM NAME="FullRowSelect" VALUE="-1">
    		        <PARAM NAME="GridLines" VALUE="-1">
    		        <PARAM NAME="HotTracking" VALUE="0">
    		        <PARAM NAME="HoverSelection" VALUE="0">
    		        <PARAM NAME="PictureAlignment" VALUE="0">
    	                <PARAM NAME="TextBackground" VALUE="0">
                            <PARAM NAME="ForeColor" VALUE="-2147483640">
    	                <PARAM NAME="BackColor" VALUE="-2147483624">
    		        <PARAM NAME="BorderStyle" VALUE="0">
    		        <PARAM NAME="Appearance" VALUE="0">
    		        <PARAM NAME="MousePointer" VALUE="0">
    		        <PARAM NAME="Enabled" VALUE="1">
    		        <PARAM NAME="NumItems" VALUE="0">
    	   		<param name="OLEDragMode" value="0">
    			<param name="OLEDropMode" value="0">
    </OBJECT>
     
    <td width="540" height="220" style="border: 1px solid #C0C0C0">
    <OBJECT ID="ListView2" WIDTH=540 HEIGHT=220 CLASSID="CLSID:BDD1F04B-858B-11D1-B16A-00C0F0283628">
    		        <PARAM NAME="SortKey" VALUE="0">
    		        <PARAM NAME="View" VALUE="3">
    		        <PARAM NAME="Arrange" VALUE="0">
    		        <PARAM NAME="LabelEdit" VALUE="1">
    		        <PARAM NAME="SortOrder" VALUE="0">
    		        <PARAM NAME="Sorted" VALUE="-1">
    		        <PARAM NAME="MultiSelect" VALUE="0">
    		        <PARAM NAME="LabelWrap" VALUE="-1">
    		        <PARAM NAME="HideSelection" VALUE="0">
    		        <PARAM NAME="HideColumnHeaders" VALUE="0">
    		        <PARAM NAME="OLEDragMode" VALUE="0">
    		        <PARAM NAME="OLEDropMode" VALUE="0">
    		        <PARAM NAME="AllowReorder" VALUE="-1">
    		        <PARAM NAME="Checkboxes" VALUE="0">
    		        <PARAM NAME="FlatScrollBar" VALUE="0">
    		        <PARAM NAME="FullRowSelect" VALUE="-1">
    		        <PARAM NAME="GridLines" VALUE="-1">
    		        <PARAM NAME="HotTracking" VALUE="0">
    		        <PARAM NAME="HoverSelection" VALUE="0">
    		        <PARAM NAME="PictureAlignment" VALUE="0">
    	                <PARAM NAME="TextBackground" VALUE="0">
                            <PARAM NAME="ForeColor" VALUE="-2147483640">
    	                <PARAM NAME="BackColor" VALUE="-2147483624">
    		        <PARAM NAME="BorderStyle" VALUE="0">
    		        <PARAM NAME="Appearance" VALUE="0">
    		        <PARAM NAME="MousePointer" VALUE="0">
    		        <PARAM NAME="Enabled" VALUE="1">
    		        <PARAM NAME="NumItems" VALUE="0">
    	   		<param name="OLEDragMode" value="0">
    			<param name="OLEDropMode" value="0">
    </OBJECT>
     
    </td>
    </tr>
     
    <table WIDTH="100%" BORDER=1>
    <td VALIGN=TOP WIDTH="25%" COLSPAN=2>
    <table BORDER=0>
    </fieldset>
     
    <center>
    </table>
    <fieldset>
    <br>
    <input id=Quitbutton  class="button" type="button" value="   Quit   " name="Quitter_Button"  onClick="Quitter">
    </center>
    <br>
    </fieldset>
    </body>
    </html>
    ton fichier computer.txt doit ressembler à ca :

    Web;PCIA-EXP-BAL2SIR-Bal2Xml;PCIA-EXP-BAL2SIR-FormatSrc2FormatDest;PCIA-EXP-CNET2ACTES;PCIA-EXP-DAP2ACCUS-Bal2Xml;PCIA-EXP-DAP2ACCUS;PCIA-EXP-DAP2ACCUS-ERR;
    SIHSGDB;PCIA-EXP-DAP2DATA;PCIA-EXP-ACCUS2DAP;PCIA-EXP-ACCUS2DAP-ERR

    tu commences une ligne par le nom de ta machine, puis sur la meme ligne, tu mets le nom des tes services séparé par un ";".

    A++
    Plus tu pédales moins vite, moins t'avances plus vite.

  15. #15
    Futur Membre du Club
    Profil pro
    Inscrit en
    Mars 2008
    Messages
    13
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mars 2008
    Messages : 13
    Points : 8
    Points
    8
    Par défaut
    j'ai bien cherché un bug ou quelque chose à dire mais non c'est parfaitement ce que j'avai imaginé au début et en mieux.

    c'est assez impressionnant la vitesse à laquel tu à adapté ce code encore merci et surtout bravo

  16. #16
    Expert confirmé
    Avatar de ced600
    Homme Profil pro
    Développeur .NET
    Inscrit en
    Août 2006
    Messages
    3 364
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 42
    Localisation : France

    Informations professionnelles :
    Activité : Développeur .NET

    Informations forums :
    Inscription : Août 2006
    Messages : 3 364
    Points : 4 061
    Points
    4 061
    Par défaut
    la gestion des alertes est casiment déjà présente par les 10 appels que j'ai dans la minutes ou certains services tombent
    Tu fais la relance des services à la main ?
    Parce que si oui sache que cela peut s'automatiser, donc ....
    Pourquoi faire compliqué lorsque l'on peut faire encore plus compliqué.

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Réponses: 0
    Dernier message: 22/12/2014, 10h58
  2. Afficher image sous condition
    Par barchetta90 dans le forum Général JavaScript
    Réponses: 1
    Dernier message: 07/12/2013, 22h26
  3. Afficher image sous condition
    Par wachoo31 dans le forum IHM
    Réponses: 10
    Dernier message: 27/01/2008, 10h22
  4. afficher une image selon condition
    Par sakia dans le forum VBA Access
    Réponses: 4
    Dernier message: 04/10/2007, 17h40
  5. Afficher une image sous condition
    Par Chmog dans le forum BIRT
    Réponses: 5
    Dernier message: 28/07/2006, 12h11

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo