Précédent   Forum du club des développeurs et IT Pro > Autres langages > Général Visual Basic 6 et VBScript > VBScript
VBScript Le forum d'entraide sur VBScript. Avant de poster -> La FAQ VBScript
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse
 
Outils de la discussion
Publicité
'
Vieux 12/12/2012, 14h31   #1
panda10b
Candidat au titre de Membre du Club
 
Homme bastien vuillemard
Administrateur systèmes et réseaux
Inscription : décembre 2012
Messages : 10
Détails du profil
Informations personnelles :
Nom : Homme bastien vuillemard
Localisation : France, Aube (Champagne Ardenne)

Informations professionnelles :
Activité : Administrateur systèmes et réseaux
Secteur : Enseignement

Informations forums :
Inscription : décembre 2012
Messages : 10
Points : 14
Points : 14
Par défaut Script pour éteindre des postes a distance

bonjour a tous,

Je ne connais vraiment rien en VBS pour être honnête.

j'ai un .bat qui me permet de faire un ping sur des ordinateur a partir d'un fichier .TXT et en fonction de la réponse, il lance un shutdown qui ferme les postes. Avec en plus un fichier de résultat qui m'indique si l'ordinateur était allumé ou éteint lors du ping.
ce script est utilisé dans le cadre d'une FAC et permet de fermer les ordinateur restés allumés le soir.

Je voudrais faire un script en vbs si possible qui ping mes postes (toujours a partir de mon .TXT avec les adresses IP) et qui en fonction de la réponse lance plusieurs choses.
Dans un premier temps, exécuter la commande d'arrêt du poste si le ping répond
Puis ouvrir une box proposant a l'utilisateur d'interrompre le processus d'arrêt avec par exemple un message" Ordinateur en cours d'arrêt!!!Appuyer sur OK pour pouvoir continuer a travail"
Si l'utilisateur appui sur OK alors l'ordinateur ne s'arrête pas

J'aimerais si possible que la box qui s'ouvrirait reste active 60 secondes et que si il n'y a pas d'action l'arrêt ce fasse

Pour finir je souhaite pouvoir consulté sur mon serveur un fichier de LOG qui me précisera si l'ordinateur était déjà éteint ou s'il s'est éteint ou si l'utilisateur a interrompu le processus.

Je ne souhaite pas forcement que l'on me donne un script tout fait mais au cas ou je prendrais.
Sinon de l'aide de toute sorte sera la bienvenue

Merci
panda10b est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 12/12/2012, 14h51   #2
hackoofr
Expert Confirmé
 
Avatar de hackoofr
 
Homme Mehdi Tounisiano
Enseignant
Inscription : juin 2009
Messages : 1 702
Détails du profil
Informations personnelles :
Nom : Homme Mehdi Tounisiano
Âge : 38
Localisation : Tunisie

Informations professionnelles :
Activité : Enseignant

Informations forums :
Inscription : juin 2009
Messages : 1 702
Points : 3 886
Points : 3 886
et Bienvenue sur DVP
Pouvez-vous poster votre Script BATCH ?
hackoofr est actuellement connecté   Envoyer un message privé Réponse avec citation 10
Vieux 12/12/2012, 15h02   #3
panda10b
Candidat au titre de Membre du Club
 
Homme bastien vuillemard
Administrateur systèmes et réseaux
Inscription : décembre 2012
Messages : 10
Détails du profil
Informations personnelles :
Nom : Homme bastien vuillemard
Localisation : France, Aube (Champagne Ardenne)

Informations professionnelles :
Activité : Administrateur systèmes et réseaux
Secteur : Enseignement

Informations forums :
Inscription : décembre 2012
Messages : 10
Points : 14
Points : 14
Bonjour,

Voici mon code en batch
Citation:
@echo off

del C:\WOL\arret\Resultat\Multimedia.txt

echo %date% %time% >> C:\WOL\arret\Resultat\Multimedia.txt
echo. >> C:\WOL\arret\Resultat\Multimedia.txt

FOR /F %%I in (C:\wol\Arret\adripmedia.txt) DO (PING -n 1 -w 4 %%I | FIND "TTL=">NUL
IF NOT ERRORLEVEL 1 (
shutdown -s -f -t 180 -m \\%%I -c "EXTINCTION DE L'ORDINATEUR.Vous avez 3 minutes pour sauvegarder votre travail avant l'arret complet du poste."

echo poste %%I arrêt en cours >> C:\WOL\arret\Resultat\Multimedia.txt

) else (
echo poste %%I deja eteinte >> C:\WOL\arret\Resultat\Multimedia.txt
)
)
Merci de prendre le temps de répondre
panda10b est déconnecté   Envoyer un message privé Réponse avec citation 10
Vieux 12/12/2012, 15h48   #4
hackoofr
Expert Confirmé
 
Avatar de hackoofr
 
Homme Mehdi Tounisiano
Enseignant
Inscription : juin 2009
Messages : 1 702
Détails du profil
Informations personnelles :
Nom : Homme Mehdi Tounisiano
Âge : 38
Localisation : Tunisie

Informations professionnelles :
Activité : Enseignant

Informations forums :
Inscription : juin 2009
Messages : 1 702
Points : 3 886
Points : 3 886

Jetez un coup d’œil dans cette Discussion qui a presque la même problématique : Transformation d'un programme DOS en VBScript pour reboot de 1 ou plusieurs micro
hackoofr est actuellement connecté   Envoyer un message privé Réponse avec citation 20
Vieux 12/12/2012, 16h15   #5
panda10b
Candidat au titre de Membre du Club
 
Homme bastien vuillemard
Administrateur systèmes et réseaux
Inscription : décembre 2012
Messages : 10
Détails du profil
Informations personnelles :
Nom : Homme bastien vuillemard
Localisation : France, Aube (Champagne Ardenne)

Informations professionnelles :
Activité : Administrateur systèmes et réseaux
Secteur : Enseignement

Informations forums :
Inscription : décembre 2012
Messages : 10
Points : 14
Points : 14
j'avais fait quelque recherche avant de déranger tout le monde et j'ai déjà vu ce topic merci!!!!
je l'ai essayer mais il reste un petit mystère pour moi.

Je rappelle humblement que je ne comprend rien au VBS, j'arrive juste a faire un Msgbox sur mon ordi pour le moment!!!
Je comprend le principe et les actions mais je ne sais pas du tout comment agir deçu

Le script du topic que tu m'a indiqué passe par une interface web avec inscription d'un mot de passe alors que je souhaiterai avoir un script que je puisse exécuter en tache planifié.

De plus, si je peux me permettre, il ne fonctionne pas entièrement: Je m'explique, le script du topic je l'ai ajusté avec mon fichier d'adresse IP.
Il permet en effet le reboot du premier poste mais il ne se passe rien sur les suivants et la page web ne se ferme pas.
Pour finir, le script indique une erreur a la ligne 139 au caractère 5

je sais que je suis chiant
panda10b est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 13/12/2012, 09h44   #6
panda10b
Candidat au titre de Membre du Club
 
Homme bastien vuillemard
Administrateur systèmes et réseaux
Inscription : décembre 2012
Messages : 10
Détails du profil
Informations personnelles :
Nom : Homme bastien vuillemard
Localisation : France, Aube (Champagne Ardenne)

Informations professionnelles :
Activité : Administrateur systèmes et réseaux
Secteur : Enseignement

Informations forums :
Inscription : décembre 2012
Messages : 10
Points : 14
Points : 14
Bonjour,

Hackoofr, j'ai suivi votre conseil avec le topic que vous m'avez indiqué.
J'ai enlevé mes moufles aussi ça aide pour travailler.
J'ai avancé et compris le principe du topic.
J'ai trouver comment faire l'arrêt du poste mais tout mes voeux ne sont pas réalisé!!!!
premièrement il se pose un problème le script fonctionne lorsque je désactive le pare-feu
auriez vous les ports a ouvrir car c'est un peu gênant de tout laisser open.

Deuxièmement comment est ce que je peux éviter l'ouverture de la fenêtre et l'entré du mot de passe.

Merci de votre aide
panda10b est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 13/12/2012, 12h28   #7
hackoofr
Expert Confirmé
 
Avatar de hackoofr
 
Homme Mehdi Tounisiano
Enseignant
Inscription : juin 2009
Messages : 1 702
Détails du profil
Informations personnelles :
Nom : Homme Mehdi Tounisiano
Âge : 38
Localisation : Tunisie

Informations professionnelles :
Activité : Enseignant

Informations forums :
Inscription : juin 2009
Messages : 1 702
Points : 3 886
Points : 3 886
Citation:
Envoyé par panda10b Voir le message
Bonjour,
Hackoofr, j'ai suivi votre conseil avec le topic que vous m'avez indiqué.
J'ai enlevé mes moufles aussi ça aide pour travailler.
J'ai avancé et compris le principe du topic.
J'ai trouver comment faire l'arrêt du poste mais tout mes voeux ne sont pas réalisé!!!!
premièrement il se pose un problème le script fonctionne lorsque je désactive le pare-feu
auriez vous les ports a ouvrir car c'est un peu gênant de tout laisser open.
Deuxièmement comment est ce que je peux éviter l'ouverture de la fenêtre et l'entré du mot de passe.
Merci de votre aide

postez votre vbscript modifié !
hackoofr est actuellement connecté   Envoyer un message privé Réponse avec citation 00
Vieux 13/12/2012, 12h39   #8
Daynvheur
Nouveau Membre du Club
 
Technicien Help Desk
Inscription : décembre 2012
Messages : 23
Détails du profil
Informations personnelles :
Localisation : France

Informations professionnelles :
Activité : Technicien Help Desk

Informations forums :
Inscription : décembre 2012
Messages : 23
Points : 29
Points : 29
Citation:
Envoyé par panda10b Voir le message
premièrement il se pose un problème le script fonctionne lorsque je désactive le pare-feu
auriez vous les ports a ouvrir car c'est un peu gênant de tout laisser open.
Ouvre (en tant qu'administrateur) le SecPol.msc sur l'ordinateur cible, dans la fenêtre "Paramètres de sécurité locaux", "Stratégies locales > Attribution des droits utilisateur", vérifie qu'au-moins le compte administrateur que tu souhaites utiliser a les droits de "Forcer l'arrêt à partir d'un système distant".

Si tu as un contrôleur de domaine à disposition et que ce paramètre n'est pas fixé correctement, je t'invite à modifier la GPO.
Citation:
Deuxièmement comment est ce que je peux éviter l'ouverture de la fenêtre et l'entré du mot de passe.

Merci de votre aide
Je rejoins hackoofr : sans le script modifié, difficile de savoir la ligne de commande appelée.
Daynvheur est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 14/12/2012, 09h39   #9
panda10b
Candidat au titre de Membre du Club
 
Homme bastien vuillemard
Administrateur systèmes et réseaux
Inscription : décembre 2012
Messages : 10
Détails du profil
Informations personnelles :
Nom : Homme bastien vuillemard
Localisation : France, Aube (Champagne Ardenne)

Informations professionnelles :
Activité : Administrateur systèmes et réseaux
Secteur : Enseignement

Informations forums :
Inscription : décembre 2012
Messages : 10
Points : 14
Points : 14
voici le code messieurs


Code :
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
'*** Définition des variables globale ***
 
    Titre = "Arrêt de postes à distance @ Developpez.com"
    Const ForReading = 1, ForWriting = 8
    Public StrComputer, onlinestate, Fichier_log, WSHShell, Fichier_tmp, msg()
    Dim oFSO, oFl, ecr, lect, ComputerName
    Set oFSO = WScript.CreateObject("Scripting.FileSystemObject")
    Set WSHShell = WScript.CreateObject("WScript.Shell")
    Set WSHNetwork = CreateObject("WScript.Network")
 
' *** Définition des variables d'environnement ***
 
    Liste_pc = "adrip1.txt"
    Fichier_tmp = "LISTE_TMP.txt"
    Fichier_log = "RAPPORT_RESTART.txt"
 
' *** Définition des variables locales ***
 
    Redim msg(7)
    msg(0) = "__________________________________________"
    msg(1) = "Liste des postes introuvable " & dblquote(Liste_pc)
    msg(2) = "Aucun poste dans la liste " & dblquote(Liste_pc)
    msg(3) = "Début du script : "
    msg(4) = "Script interrompu : "
    msg(5) = "Fin du script : "
    msg(6) = " : Poste inaccessible"
    msg(7) = " : Arrêt demandé"
 
 
' *** Début du Script ***
 
    ' Test Fichier_Log existe
    If Not oFSO.FileExists(Fichier_log) Then oFSO.CreateTextFile(Fichier_log)
    Date_Heure = now
    Set ecr = oFSO.OpenTextFile(Fichier_log, ForWriting) : ecr.Write msg(3) & Date_Heure & VbCrLf & VbCrLf : ecr.Close
 
    ' Test Liste_Pc existe
    If Not oFSO.FileExists(Liste_Pc) Then
    Set ecr = oFSO.OpenTextFile(Fichier_log, ForWriting) : ecr.Write msg(1) & VbCrLf : ecr.Close : Call fin_Prog : WScript.Quit
    End If
 
    ' Test Liste_Pc non vide
    Set oFl = oFSO.GetFile(Liste_Pc)
    If oFl.Size = 0 Then
    Set ecr = oFSO.OpenTextFile(Fichier_log, ForWriting) : ecr.Write msg(2) & VbCrLf : ecr.Close : Call fin_Prog : WScript.Quit
    End If
 
    ' Création Fichier_tmp
    if oFSO.FileExists(Fichier_tmp) Then oFSO.DeleteFile Fichier_tmp, True
    oFSO.CreateTextFile(Fichier_tmp)
 
    ' Correction de Liste_Pc en Fichier_tmp
 
    date_heure = now
    Set lect = oFSO.OpenTextFile(Liste_Pc, ForReading)
    Set ecr = oFSO.OpenTextFile(Fichier_tmp, ForWriting)
        While Not lect.AtEndOfStream
        Texte = lect.ReadLine
        Texte = Trim(Texte)
        prem_car = lcase(left(Texte,1))
            if ( Len(Texte) > 0 ) and InStr("'", prem_car) = 0 Then
            ecr.Writeline Texte
            End if    
        Wend
    lect.Close
    ecr.Close
 
    ' Test Fichier_tmp non vide
 
    Set oFl = oFSO.GetFile(Fichier_tmp)
    If oFl.Size = 0 Then
    Set ecr = oFSO.OpenTextFile(Fichier_log, ForWriting) : ecr.Write msg(2) & VbCrLf : ecr.Close : Call fin_Prog : WScript.Quit
    End If
 
    ' Lecture du Fichier_tmp
 
    Set lect = oFSO.OpenTextFile(Fichier_tmp, ForReading)
    st = lect.ReadAll
    ComputerName = Split(st, vbCrLf)
    lect.Close
 
    ' Saisie compte Admin
 
    Set objIE = CreateObject( "InternetExplorer.Application" )
    objIE.Navigate "about:blank"
    objIE.Document.Title = "Reboot à Distance © Developpez.com" & String( 5, "*" )
    objIE.ToolBar        = False
    objIE.Resizable      = False
    objIE.StatusBar      = False
    objIE.Width          = 300
    objIE.Height         = 220
    With objIE.Document.ParentWindow.Screen
    objIE.Left = (.AvailWidth  - objIE.Width ) \ 2
    objIE.Top  = (.Availheight - objIE.Height) \ 2
    End With
    Do While objIE.Busy
    WScript.Sleep 200
    Loop
 
 
    objIE.Document.Body.InnerHTML = "<div align=""center""><p><h3 style='color:Red'>Nom Utilisateur " _
        & "<br><input type=""text"" style='color:Blue' size=""20"" " _
        & "id=""Login"" value=""Administrateur""></h3></p>"_
        & "</p><p><h3 style='color:Red'>Mot de passe<br><input type=""password"" style='color:Blue' size=""20"" " _
        & "id=""Password""></h3></p><p><input type=" _
        & """hidden"" id=""OK"" name=""OK"" value=""0"">" _
        & "<input type=""submit"" value="" stop "" " _
        & "onclick=""VBScript:OK.Value=1""></p></div>"
    objIE.Document.Body.Style.overflow = "auto"
    objIE.Document.body.style.backgroundcolor="lightblue"
    objIE.Visible = True
    objIE.Document.All.Password.Focus
 
    On Error Resume Next
    Do While objIE.Document.All.OK.Value = 0
    WScript.Sleep 200
    If Err Then    
        IELogin = Array( "", "" )
        objIE.Quit
        Set objIE = Nothing
        wscript.quit
    End if
    Loop
 
    On Error Goto 0
    Login = objIE.Document.All.Login.Value
    Password = objIE.Document.All.Password.Value
    For i = lbound(ComputerName) to ubound(ComputerName) -1
    strComputer = ComputerName(i)
    Call Online
    If onlinestate = 0 Then
    Set ecr = oFSO.OpenTextFile(Fichier_log, ForWriting) : ecr.Write ComputerName(i) & msg(6) & VbCrLf : ecr.Close
    Else
    command = "cmd /c wmic /node:"&ComputerName(i)&" /user:"&dblquote(Login)&" /password:"&dblquote(Password)&" os where primary=true call shutdown"
    Execution = WSHShell.Run(Command,0,True)
    Set ecr = oFSO.OpenTextFile(Fichier_log, ForWriting) : ecr.Write ComputerName(i) & msg(7) & VbCrLf : ecr.Close
    End if
    Next
    objIE.Quit
    Set objIE = Nothing
 
' *** Fin du script
 
Date_Heure = now
Set ecr = oFSO.OpenTextFile(Fichier_log, ForWriting) :  ecr.Write VbNewLine & msg(5) & Date_Heure & VbCrLf & msg(0) & VbCrLf : ecr.Close
if oFSO.FileExists(Fichier_tmp) Then oFSO.DeleteFile Fichier_tmp, True
WSHShell.Run ("C:\WINDOWS\system32\notepad.exe " & Fichier_log)
WScript.Quit
 
' *** Sous-Fonction Fin programme
 
Sub fin_prog
Date_Heure = now
Set ecr = oFSO.OpenTextFile(Fichier_log, ForWriting) :  ecr.Write VbNewLine & msg(4) & Date_Heure & VbCrLf & msg(0) & VbCrLf : ecr.Close
if oFSO.FileExists(Fichier_tmp) Then oFSO.DeleteFile Fichier_tmp, True
WSHShell.Run ("C:\WINDOWS\system32\notepad.exe " & Fichier_log)
End Sub
 
' *** Sous-Fonction Ping
 
Sub online
Set objPing = GetObject("winmgmts:{impersonationLevel=impersonate}!\\").ExecQuery("select * from Win32_PingStatus where address = '" & StrComputer & "'")
For Each objStatus in objPing
If objStatus.Statuscode = 0 Then onlinestate = 1 else onlinestate = 0
Next
End Sub
 
 
' *** Fonction Guillemets
 
Function dblquote(strIn)
dblquote = Chr(34) & strIn & Chr(34)
End Function
pour info, j'ai vérifier le paramétrage dans le Secpol.msc
Citation:
Ouvre (en tant qu'administrateur) le SecPol.msc sur l'ordinateur cible, dans la fenêtre "Paramètres de sécurité locaux", "Stratégies locales > Attribution des droits utilisateur", vérifie qu'au-moins le compte administrateur que tu souhaites utiliser a les droits de "Forcer l'arrêt à partir d'un système distant".
mon administrateur a bien les droits mais je ne peut pas arréter l'ordinateur le pare-feu me bloque alors que le .bat que j'ai mis dans mon 2ème post est opérationnel

Merci du temps que vous m'accordez
panda10b est déconnecté   Envoyer un message privé Réponse avec citation 10
Vieux 14/12/2012, 13h08   #10
hackoofr
Expert Confirmé
 
Avatar de hackoofr
 
Homme Mehdi Tounisiano
Enseignant
Inscription : juin 2009
Messages : 1 702
Détails du profil
Informations personnelles :
Nom : Homme Mehdi Tounisiano
Âge : 38
Localisation : Tunisie

Informations professionnelles :
Activité : Enseignant

Informations forums :
Inscription : juin 2009
Messages : 1 702
Points : 3 886
Points : 3 886

voici le script sans la boîte de saisie mais il y a encore du travail pour qu'il soit fonctionnel à 100% car je ne peux pas le tester (pas de réseau)
peut-être un administrateur réseau nous donne une bonne solution
Bonne Chance
Code :
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
'*** Définition des variables globale ***
    Const ForReading = 1, ForWriting = 8
    Public StrComputer, onlinestate, Fichier_log, WSHShell, Fichier_tmp, msg()
    Dim oFSO, oFl, ecr, lect, ComputerName
    Set oFSO = WScript.CreateObject("Scripting.FileSystemObject")
    Set WSHShell = WScript.CreateObject("WScript.Shell")
    Set WSHNetwork = CreateObject("WScript.Network")
 ' *** Définition des variables d'environnement ***
    Liste_pc = "adrip1.txt"
    Fichier_tmp = "LISTE_TMP.txt"
    Fichier_log = "RAPPORT_RESTART.txt" 
' *** Définition des variables locales ***
    Redim msg(7)
    msg(0) = "__________________________________________"
    msg(1) = "Liste des postes introuvable " & dblquote(Liste_pc)
    msg(2) = "Aucun poste dans la liste " & dblquote(Liste_pc)
    msg(3) = "Début du script : "
    msg(4) = "Script interrompu : "
    msg(5) = "Fin du script : "
    msg(6) = " : Poste inaccessible"
    msg(7) = " : Arrêt demandé"
' *** Début du Script ***
    ' Test Fichier_Log existe
    If Not oFSO.FileExists(Fichier_log) Then oFSO.CreateTextFile(Fichier_log)
    Date_Heure = now
    Set ecr = oFSO.OpenTextFile(Fichier_log, ForWriting) : ecr.Write msg(3) & Date_Heure & VbCrLf & VbCrLf : ecr.Close
    ' Test Liste_Pc existe
    If Not oFSO.FileExists(Liste_Pc) Then
    Set ecr = oFSO.OpenTextFile(Fichier_log, ForWriting) : ecr.Write msg(1) & VbCrLf : ecr.Close : Call fin_Prog : WScript.Quit
    End If
    ' Test Liste_Pc non vide
    Set oFl = oFSO.GetFile(Liste_Pc)
    If oFl.Size = 0 Then
    Set ecr = oFSO.OpenTextFile(Fichier_log, ForWriting) : ecr.Write msg(2) & VbCrLf : ecr.Close : Call fin_Prog : WScript.Quit
    End If
    ' Création Fichier_tmp
    if oFSO.FileExists(Fichier_tmp) Then oFSO.DeleteFile Fichier_tmp, True
    oFSO.CreateTextFile(Fichier_tmp)
    ' Correction de Liste_Pc en Fichier_tmp
    date_heure = now
    Set lect = oFSO.OpenTextFile(Liste_Pc, ForReading)
    Set ecr = oFSO.OpenTextFile(Fichier_tmp, ForWriting)
        While Not lect.AtEndOfStream
        Texte = lect.ReadLine
        Texte = Trim(Texte)
        prem_car = lcase(left(Texte,1))
            if ( Len(Texte) > 0 ) and InStr("'", prem_car) = 0 Then
            ecr.Writeline Texte
            End if    
        Wend
    lect.Close
    ecr.Close
    ' Test Fichier_tmp non vide
    Set oFl = oFSO.GetFile(Fichier_tmp)
    If oFl.Size = 0 Then
    Set ecr = oFSO.OpenTextFile(Fichier_log, ForWriting) : ecr.Write msg(2) & VbCrLf : ecr.Close : Call fin_Prog : WScript.Quit
    End If
    ' Lecture du Fichier_tmp
    Set lect = oFSO.OpenTextFile(Fichier_tmp, ForReading)
    st = lect.ReadAll
    ComputerName = Split(st, vbCrLf)
    lect.Close
    ' Saisie compte Admin et password
    Login = "administrateur"
    Password = "votre mot de passe" ' à modifier
    '---------------------------------------------
    For i = lbound(ComputerName) to ubound(ComputerName) -1
    strComputer = ComputerName(i)
    Call Online
    If onlinestate = 0 Then
    Set ecr = oFSO.OpenTextFile(Fichier_log, ForWriting) : ecr.Write ComputerName(i) & msg(6) & VbCrLf : ecr.Close
    Else
    command = "cmd /c wmic /node:"&ComputerName(i)&" /user:"&dblquote(Login)&" /password:"&dblquote(Password)&" os where primary=true call shutdown"
    Execution = WSHShell.Run(Command,0,True)
    Set ecr = oFSO.OpenTextFile(Fichier_log, ForWriting) : ecr.Write ComputerName(i) & msg(7) & VbCrLf : ecr.Close
    End if
    Next
' *** Fin du script 
Date_Heure = now
Set ecr = oFSO.OpenTextFile(Fichier_log, ForWriting) :  ecr.Write VbNewLine & msg(5) & Date_Heure & VbCrLf & msg(0) & VbCrLf : ecr.Close
if oFSO.FileExists(Fichier_tmp) Then oFSO.DeleteFile Fichier_tmp, True
WSHShell.Run ("notepad.exe " & Fichier_log)
WScript.Quit
' *** Sous-Fonction Fin programme 
Sub fin_prog
Date_Heure = now
Set ecr = oFSO.OpenTextFile(Fichier_log, ForWriting) :  ecr.Write VbNewLine & msg(4) & Date_Heure & VbCrLf & msg(0) & VbCrLf : ecr.Close
if oFSO.FileExists(Fichier_tmp) Then oFSO.DeleteFile Fichier_tmp, True
WSHShell.Run ("notepad.exe " & Fichier_log)
End Sub
' *** Sous-Fonction Ping
Sub online
Set objPing = GetObject("winmgmts:{impersonationLevel=impersonate}!\\").ExecQuery("select * from Win32_PingStatus where address = '" & StrComputer & "'")
For Each objStatus in objPing
If objStatus.Statuscode = 0 Then onlinestate = 1 else onlinestate = 0
Next
End Sub
' *** Fonction Guillemets
Function dblquote(strIn)
dblquote = Chr(34) & strIn & Chr(34)
End Function
hackoofr est actuellement connecté   Envoyer un message privé Réponse avec citation 10
Vieux 14/12/2012, 15h53   #11
panda10b
Candidat au titre de Membre du Club
 
Homme bastien vuillemard
Administrateur systèmes et réseaux
Inscription : décembre 2012
Messages : 10
Détails du profil
Informations personnelles :
Nom : Homme bastien vuillemard
Localisation : France, Aube (Champagne Ardenne)

Informations professionnelles :
Activité : Administrateur systèmes et réseaux
Secteur : Enseignement

Informations forums :
Inscription : décembre 2012
Messages : 10
Points : 14
Points : 14
Merci beaucoup je teste et je tiens au courant!!!!

Donc après quelque testes le script fonctionne correctement c'est super
Encore Merci
une dernière chose est qu'il est possible que l'arret soir retardé
(en .bat il y a la fonction -t 60 par exemple )

Il reste juste un soucis c'est qu'il faut absolument faire sauter le parefeu pour qu'il fonctionne.

si quelqu'un a une idée
panda10b est déconnecté   Envoyer un message privé Réponse avec citation 10
Vieux 14/12/2012, 18h52   #12
hackoofr
Expert Confirmé
 
Avatar de hackoofr
 
Homme Mehdi Tounisiano
Enseignant
Inscription : juin 2009
Messages : 1 702
Détails du profil
Informations personnelles :
Nom : Homme Mehdi Tounisiano
Âge : 38
Localisation : Tunisie

Informations professionnelles :
Activité : Enseignant

Informations forums :
Inscription : juin 2009
Messages : 1 702
Points : 3 886
Points : 3 886

Citation:
Envoyé par panda10b Voir le message
Donc après quelque testes le script fonctionne correctement c'est super
une dernière chose est qu'il est possible que l'arret soir retardé
(en .bat il y a la fonction -t 60 par exemple )
Il reste juste un soucis c'est qu'il faut absolument faire sauter le parefeu pour qu'il fonctionne.
si quelqu'un a une idée
Donc le script fonctionne en local et non pas en réseau
Testez ce code :
Code :
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
'*** Définition des variables globale ***
Const ForReading = 1, ForWriting = 8
Public StrComputer, onlinestate, Fichier_log, WSHShell, Fichier_tmp, msg()
Dim oFSO, oFl, ecr, lect, ComputerName
Set oFSO = WScript.CreateObject("Scripting.FileSystemObject")
Set WSHShell = WScript.CreateObject("WScript.Shell")
Set WSHNetwork = CreateObject("WScript.Network")
' *** Définition des variables d'environnement ***
Liste_pc = "adrip1.txt"
Fichier_tmp = "LISTE_TMP.txt"
Fichier_log = "RAPPORT_RESTART.txt" 
' *** Définition des variables locales ***
Redim msg(7)
msg(0) = "__________________________________________"
msg(1) = "Liste des postes introuvable " & dblquote(Liste_pc)
msg(2) = "Aucun poste dans la liste " & dblquote(Liste_pc)
msg(3) = "Début du script : "
msg(4) = "Script interrompu : "
msg(5) = "Fin du script : "
msg(6) = " : Poste inaccessible"
msg(7) = " : Arrêt demandé"
' *** Début du Script ***
' Test Fichier_Log existe
If Not oFSO.FileExists(Fichier_log) Then oFSO.CreateTextFile(Fichier_log)
Date_Heure = now
Set ecr = oFSO.OpenTextFile(Fichier_log, ForWriting) : ecr.Write msg(3) & Date_Heure & VbCrLf & VbCrLf : ecr.Close
' Test Liste_Pc existe
If Not oFSO.FileExists(Liste_Pc) Then
    Set ecr = oFSO.OpenTextFile(Fichier_log, ForWriting) : ecr.Write msg(1) & VbCrLf : ecr.Close : Call fin_Prog : WScript.Quit
End If
' Test Liste_Pc non vide
Set oFl = oFSO.GetFile(Liste_Pc)
If oFl.Size = 0 Then
    Set ecr = oFSO.OpenTextFile(Fichier_log, ForWriting) : ecr.Write msg(2) & VbCrLf : ecr.Close : Call fin_Prog : WScript.Quit
End If
' Création Fichier_tmp
if oFSO.FileExists(Fichier_tmp) Then oFSO.DeleteFile Fichier_tmp, True
oFSO.CreateTextFile(Fichier_tmp)
' Correction de Liste_Pc en Fichier_tmp
date_heure = now
Set lect = oFSO.OpenTextFile(Liste_Pc, ForReading)
Set ecr = oFSO.OpenTextFile(Fichier_tmp, ForWriting)
While Not lect.AtEndOfStream
    Texte = lect.ReadLine
    Texte = Trim(Texte)
    prem_car = lcase(left(Texte,1))
    if ( Len(Texte) > 0 ) and InStr("'", prem_car) = 0 Then
        ecr.Writeline Texte
    End if    
Wend
lect.Close
ecr.Close
' Test Fichier_tmp non vide
Set oFl = oFSO.GetFile(Fichier_tmp)
If oFl.Size = 0 Then
    Set ecr = oFSO.OpenTextFile(Fichier_log, ForWriting) : ecr.Write msg(2) & VbCrLf : ecr.Close : Call fin_Prog : WScript.Quit
End If
' Lecture du Fichier_tmp
Set lect = oFSO.OpenTextFile(Fichier_tmp, ForReading)
st = lect.ReadAll
ComputerName = Split(st, vbCrLf)
lect.Close
' Saisie compte Admin et password
Login = "administrateur"
Password = "votre mot de passe" ' à modifier
Avertissement = "EXTINCTION DE L'ORDINATEUR.Vous avez 3 minutes pour sauvegarder votre travail avant l'arrêt complet du poste"
Attente = "180" 'Attente de 3 minutes pour sauvegarder le travail
'---------------------------------------------
For i = lbound(ComputerName) to ubound(ComputerName) -1
    strComputer = ComputerName(i)
    Call Online
    If onlinestate = 0 Then
        Set ecr = oFSO.OpenTextFile(Fichier_log, ForWriting) : ecr.Write ComputerName(i) & msg(6) & VbCrLf : ecr.Close
    Else
       'command = "cmd /c wmic /node:"&ComputerName(i)&" /user:"&dblquote(Login)&" /password:"&dblquote(Password)&" os where primary=true call reboot"
        Command = "Cmd /c shutdown.exe -m \\" & ComputerName(i) & " -s -c " & dblquote(Avertissement) & " -t " & Attente
        Execution = WSHShell.Run(Command,0,False)
        Set ecr = oFSO.OpenTextFile(Fichier_log, ForWriting) : ecr.Write ComputerName(i) & msg(7) & VbCrLf : ecr.Close
    End if
Next
' *** Fin du script 
Date_Heure = now
Set ecr = oFSO.OpenTextFile(Fichier_log, ForWriting) :  ecr.Write VbNewLine & msg(5) & Date_Heure & VbCrLf & msg(0) & VbCrLf : ecr.Close
if oFSO.FileExists(Fichier_tmp) Then oFSO.DeleteFile Fichier_tmp, True
WSHShell.Run ("notepad.exe " & Fichier_log)
WScript.Quit
' *** Sous-Fonction Fin programme 
Sub fin_prog
    Date_Heure = now
    Set ecr = oFSO.OpenTextFile(Fichier_log, ForWriting) :  ecr.Write VbNewLine & msg(4) & Date_Heure & VbCrLf & msg(0) & VbCrLf : ecr.Close
    if oFSO.FileExists(Fichier_tmp) Then oFSO.DeleteFile Fichier_tmp, True
    WSHShell.Run ("notepad.exe " & Fichier_log)
End Sub
' *** Sous-Fonction Ping
Function online
    Set objPing = GetObject("winmgmts:{impersonationLevel=impersonate}!\\").ExecQuery("select * from Win32_PingStatus where address = '" & StrComputer & "'")
    For Each objStatus in objPing
        If objStatus.Statuscode = 0 Then onlinestate = 1 else onlinestate = 0
    Next
End Function
' *** Fonction Guillemets
Function dblquote(strIn)
    dblquote = Chr(34) & strIn & Chr(34)
End Function
hackoofr est actuellement connecté   Envoyer un message privé Réponse avec citation 10
Vieux 17/12/2012, 09h24   #13
panda10b
Candidat au titre de Membre du Club
 
Homme bastien vuillemard
Administrateur systèmes et réseaux
Inscription : décembre 2012
Messages : 10
Détails du profil
Informations personnelles :
Nom : Homme bastien vuillemard
Localisation : France, Aube (Champagne Ardenne)

Informations professionnelles :
Activité : Administrateur systèmes et réseaux
Secteur : Enseignement

Informations forums :
Inscription : décembre 2012
Messages : 10
Points : 14
Points : 14
Super merci beaucoup!!!

ce script reprend presque tout ce dont j'ai besoin il me manque plus a ouvrir une box qui laisse le choix a l'utilisateur et le tour est jouer

Pour ça je vais chercher avant de revenir pleurer de l'aide

Merci pour la précisions des réponses et la rapidité

Un grand Monsieur hackoofr!!!!!!!
panda10b est déconnecté   Envoyer un message privé Réponse avec citation 10
Vieux 17/12/2012, 11h22   #14
hackoofr
Expert Confirmé
 
Avatar de hackoofr
 
Homme Mehdi Tounisiano
Enseignant
Inscription : juin 2009
Messages : 1 702
Détails du profil
Informations personnelles :
Nom : Homme Mehdi Tounisiano
Âge : 38
Localisation : Tunisie

Informations professionnelles :
Activité : Enseignant

Informations forums :
Inscription : juin 2009
Messages : 1 702
Points : 3 886
Points : 3 886
Citation:
Envoyé par panda10b Voir le message
ce script reprend presque tout ce dont j'ai besoin il me manque plus a ouvrir une box qui laisse le choix a l'utilisateur et le tour est jouer

Pour laisser la main a l’utilisateur d'annuler l'action de la fermeture du PC, je crois il serai mieux d'utiliser l'outil PsShutdown : PsShutdown a une option spéciale qui permet à l'utilisateur distant pour annuler l'opération d'arrêt. Dans ce cas, l'utilisateur obtient une boîte de dialogue avec un message, compte à rebours et un bouton pour annuler l'opération.



Code :
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
'*** Définition des variables globale ***
Const ForReading = 1, ForWriting = 8
Public StrComputer, onlinestate, Fichier_log, WSHShell, Fichier_tmp, msg()
Dim oFSO, oFl, ecr, lect, ComputerName
Set oFSO = WScript.CreateObject("Scripting.FileSystemObject")
Set WSHShell = WScript.CreateObject("WScript.Shell")
Set WSHNetwork = CreateObject("WScript.Network")
' *** Définition des variables d'environnement ***
Liste_pc = "adrip1.txt"
Fichier_tmp = "LISTE_TMP.txt"
Fichier_log = "RAPPORT_RESTART.txt" 
' *** Définition des variables locales ***
Redim msg(7)
msg(0) = "__________________________________________"
msg(1) = "Liste des postes introuvable " & dblquote(Liste_pc)
msg(2) = "Aucun poste dans la liste " & dblquote(Liste_pc)
msg(3) = "Début du script : "
msg(4) = "Script interrompu : "
msg(5) = "Fin du script : "
msg(6) = " : Poste inaccessible"
msg(7) = " : Arrêt demandé"
' *** Début du Script ***
' Test Fichier_Log existe
If Not oFSO.FileExists(Fichier_log) Then oFSO.CreateTextFile(Fichier_log)
Date_Heure = now
Set ecr = oFSO.OpenTextFile(Fichier_log, ForWriting) : ecr.Write msg(3) & Date_Heure & VbCrLf & VbCrLf : ecr.Close
' Test Liste_Pc existe
If Not oFSO.FileExists(Liste_Pc) Then
    Set ecr = oFSO.OpenTextFile(Fichier_log, ForWriting) : ecr.Write msg(1) & VbCrLf : ecr.Close : Call fin_Prog : WScript.Quit
End If
' Test Liste_Pc non vide
Set oFl = oFSO.GetFile(Liste_Pc)
If oFl.Size = 0 Then
    Set ecr = oFSO.OpenTextFile(Fichier_log, ForWriting) : ecr.Write msg(2) & VbCrLf : ecr.Close : Call fin_Prog : WScript.Quit
End If
' Création Fichier_tmp
if oFSO.FileExists(Fichier_tmp) Then oFSO.DeleteFile Fichier_tmp, True
oFSO.CreateTextFile(Fichier_tmp)
' Correction de Liste_Pc en Fichier_tmp
date_heure = now
Set lect = oFSO.OpenTextFile(Liste_Pc, ForReading)
Set ecr = oFSO.OpenTextFile(Fichier_tmp, ForWriting)
While Not lect.AtEndOfStream
    Texte = lect.ReadLine
    Texte = Trim(Texte)
    prem_car = lcase(left(Texte,1))
    if ( Len(Texte) > 0 ) and InStr("'", prem_car) = 0 Then
        ecr.Writeline Texte
    End if    
Wend
lect.Close
ecr.Close
' Test Fichier_tmp non vide
Set oFl = oFSO.GetFile(Fichier_tmp)
If oFl.Size = 0 Then
    Set ecr = oFSO.OpenTextFile(Fichier_log, ForWriting) : ecr.Write msg(2) & VbCrLf : ecr.Close : Call fin_Prog : WScript.Quit
End If
' Lecture du Fichier_tmp
Set lect = oFSO.OpenTextFile(Fichier_tmp, ForReading)
st = lect.ReadAll
ComputerName = Split(st, vbCrLf)
lect.Close
' Saisie compte Admin et password
Login = "administrateur"
Password = "votre mot de passe" ' à modifier
Avertissement = "EXTINCTION DE L'ORDINATEUR.Vous avez 3 minutes pour sauvegarder votre travail avant l'arrêt complet du poste"
Attente = "180" 'Attente de 3 minutes pour sauvegarder le travail
'---------------------------------------------
For i = lbound(ComputerName) to ubound(ComputerName) -1
    strComputer = ComputerName(i)
    Call Online
    If onlinestate = 0 Then
        Set ecr = oFSO.OpenTextFile(Fichier_log, ForWriting) : ecr.Write ComputerName(i) & msg(6) & VbCrLf : ecr.Close
    Else
       'Command = "cmd /c wmic /node:"&ComputerName(i)&" /user:"&dblquote(Login)&" /password:"&dblquote(Password)&" os where primary=true call reboot"
       'Command = "Cmd /c shutdown.exe -m \\" & ComputerName(i) & " -s -c " & dblquote(Avertissement) & " -t " & Attente
        Command = "psshutdown.exe -s -f -c -t "& Attente &" -m " & dblquote(Avertissement) & "\\"& strComputer &""
        'msgbox command
        Execution = WSHShell.Run(Command,0,True)
        Set ecr = oFSO.OpenTextFile(Fichier_log, ForWriting) : ecr.Write ComputerName(i) & msg(7) & VbCrLf : ecr.Close
    End if
Next
' *** Fin du script 
Date_Heure = now
Set ecr = oFSO.OpenTextFile(Fichier_log, ForWriting) :  ecr.Write VbNewLine & msg(5) & Date_Heure & VbCrLf & msg(0) & VbCrLf : ecr.Close
if oFSO.FileExists(Fichier_tmp) Then oFSO.DeleteFile Fichier_tmp, True
WSHShell.Run ("notepad.exe " & Fichier_log)
WScript.Quit
' *** Sous-Fonction Fin programme 
Sub fin_prog
    Date_Heure = now
    Set ecr = oFSO.OpenTextFile(Fichier_log, ForWriting) :  ecr.Write VbNewLine & msg(4) & Date_Heure & VbCrLf & msg(0) & VbCrLf : ecr.Close
    if oFSO.FileExists(Fichier_tmp) Then oFSO.DeleteFile Fichier_tmp, True
    WSHShell.Run ("notepad.exe " & Fichier_log)
End Sub
' *** Sous-Fonction Ping
Function online
    Set objPing = GetObject("winmgmts:{impersonationLevel=impersonate}!\\").ExecQuery("select * from Win32_PingStatus where address = '" & StrComputer & "'")
    For Each objStatus in objPing
        If objStatus.Statuscode = 0 Then onlinestate = 1 else onlinestate = 0
    Next
End Function
' *** Fonction Guillemets
Function dblquote(strIn)
    dblquote = Chr(34) & strIn & Chr(34)
End Function
hackoofr est actuellement connecté   Envoyer un message privé Réponse avec citation 10
Vieux 17/12/2012, 11h44   #15
panda10b
Candidat au titre de Membre du Club
 
Homme bastien vuillemard
Administrateur systèmes et réseaux
Inscription : décembre 2012
Messages : 10
Détails du profil
Informations personnelles :
Nom : Homme bastien vuillemard
Localisation : France, Aube (Champagne Ardenne)

Informations professionnelles :
Activité : Administrateur systèmes et réseaux
Secteur : Enseignement

Informations forums :
Inscription : décembre 2012
Messages : 10
Points : 14
Points : 14
Merci encore une fois!!

si j'ai bien compris Psshutdown est un logiciel que je dois installé sur les postes distants?

Sinon j'en suis arrivé a ce point avec mes msgbox mais j'arrive pas a trouvé comment les faire apparaitre sur les ordinateurs distants
Code :
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
 
' Saisie compte Admin et password
Login = "administrateur"
Password = "votre mot de passe" ' à modifier
Avertissement = "EXTINCTION DE L'ORDINATEUR.Vous avez 3 minutes pour sauvegarder votre travail avant l'arrêt complet du poste"
Attente = "180" 'Attente de 3 minutes pour sauvegarder le travail
'---------------------------------------------
For i = lbound(ComputerName) to ubound(ComputerName) -1
    strComputer = ComputerName(i)
    Call Online
    If onlinestate = 0 Then
        Set ecr = oFSO.OpenTextFile(Fichier_log, ForWriting) : ecr.Write ComputerName(i) & msg(6) & VbCrLf : ecr.Close
    Else
 
	message = Msgbox ("ARRET QUOTIDIEN!!!!! Voulez-vous continuer à travailler?" , vbYesNo+vbQuestion , "Question")
 
	if  message = vbNO then
        Command = "Cmd /c shutdown.exe -m \\" & ComputerName(i) & " -s -c " & dblquote(Avertissement) & " -t " & Attente
        Execution = WSHShell.Run(Command,0,False)
        Set ecr = oFSO.OpenTextFile(Fichier_log, ForWriting) : ecr.Write ComputerName(i) & msg(7) & VbCrLf : ecr.Close
	Else message = vbYES
	   	'Command = "Cmd /c shutdown.exe -m \\" & ComputerName(i) & " -a "
		message2 = MsgBox ("Pensez a arrêter l'ordianteur à la fin de votre travail!!! Merci" , vbOkOnly+vbExclamation , "Fin") 
		Set ecr = oFSO.OpenTextFile(Fichier_log, ForWriting) : ecr.Write ComputerName(i) & msg(8) & VbCrLf : ecr.Close
 
	End if 
 
 
    End if
Je n'ai inscrit que la parti du code qui a changer

Je sais je suis chiant et têtu
panda10b est déconnecté   Envoyer un message privé Réponse avec citation 10
Vieux 17/12/2012, 11h56   #16
hackoofr
Expert Confirmé
 
Avatar de hackoofr
 
Homme Mehdi Tounisiano
Enseignant
Inscription : juin 2009
Messages : 1 702
Détails du profil
Informations personnelles :
Nom : Homme Mehdi Tounisiano
Âge : 38
Localisation : Tunisie

Informations professionnelles :
Activité : Enseignant

Informations forums :
Inscription : juin 2009
Messages : 1 702
Points : 3 886
Points : 3 886
Citation:
Envoyé par panda10b Voir le message
si j'ai bien compris Psshutdown est un logiciel que je dois installé sur les postes distants?
PsShutdown, ainsi que la commande d'arrêt de Windows Shutdown n'a pas besoin d'être installé sur des ordinateurs distants. Mais il fonctionne comme un système distribué, a donc des exigences spécifiques en matière d'environnement réseau. Chaque fois que vous exécutez la commande à distance avec PsShutdown, il installe et démarre un service sur les ordinateurs cibles si un accès à leurs partages Admin$. Puis PsShutdown envoie une commande au service et lorsque l'opération est terminée, elle s'arrête et désinstaller des services. Par conséquent, pour utiliser PsShutdown vous devez activer le partage de fichiers sur les ordinateurs qui doivent être gérés à distance et fournir un accès au partage Admin$ par l'intermédiaire du Common Internet File System (CIFS) / Server Message Block (SMB) et Remote Procedure Call (RPC) TCP / ports IP.
hackoofr est actuellement connecté   Envoyer un message privé Réponse avec citation 10
Vieux 19/12/2012, 09h35   #17
panda10b
Candidat au titre de Membre du Club
 
Homme bastien vuillemard
Administrateur systèmes et réseaux
Inscription : décembre 2012
Messages : 10
Détails du profil
Informations personnelles :
Nom : Homme bastien vuillemard
Localisation : France, Aube (Champagne Ardenne)

Informations professionnelles :
Activité : Administrateur systèmes et réseaux
Secteur : Enseignement

Informations forums :
Inscription : décembre 2012
Messages : 10
Points : 14
Points : 14
Bonjour,


J'ai teste votre solution de Psshutdown, d'ou ma réponse un peu tardive.
Je ne suis pas tout a fait convaincu par le résultat, au niveau esthétique du moins, même si ça fonctionne.
Vous allez me dire l'esthétique, on s'en fou et c'est pas faut mais.....
Chiant de nature j'ai cherché une autre solution.

Visiblement, vu le nombre de réponse (0) que j'ai eu sur d'autre forum pour ouvrir une Msgbox sur un autre ordinateur, j'en déduis que ce n'est peut être pas possible.

serait-il possible de faire un script qui en appelle un autre sur l'ordinateur distant?

Merci du temps passer à me renseigner
panda10b est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 19/12/2012, 14h49   #18
hackoofr
Expert Confirmé
 
Avatar de hackoofr
 
Homme Mehdi Tounisiano
Enseignant
Inscription : juin 2009
Messages : 1 702
Détails du profil
Informations personnelles :
Nom : Homme Mehdi Tounisiano
Âge : 38
Localisation : Tunisie

Informations professionnelles :
Activité : Enseignant

Informations forums :
Inscription : juin 2009
Messages : 1 702
Points : 3 886
Points : 3 886
Citation:
Envoyé par panda10b Voir le message
Bonjour,
J'ai teste votre solution de Psshutdown, d'ou ma réponse un peu tardive.
Je ne suis pas tout a fait convaincu par le résultat, au niveau esthétique du moins, même si ça fonctionne.
Vous allez me dire l'esthétique, on s'en fou et c'est pas faut mais.....
Chiant de nature j'ai cherché une autre solution.

Visiblement, vu le nombre de réponse (0) que j'ai eu sur d'autre forum pour ouvrir une Msgbox sur un autre ordinateur, j'en déduis que ce n'est peut être pas possible.

serait-il possible de faire un script qui en appelle un autre sur l'ordinateur distant?

Merci du temps passer à me renseigner

une proposition est de faire copier un script dans les PC distants qui sert a annuler le shudown mais il faut que l'utilisateur l'exécute
Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
Option Explicit
Dim objShell,intShutdown,Message,strShutdown,strAbort
'Les options du Shutdown
'-s = shutdown, -t 180 = 3 minutes, -f = force les programs à s'arrêter
Message = "EXTINCTION DE L'ORDINATEUR.Vous avez 3 minutes pour sauvegarder votre travail avant l'arrêt complet du poste"
strShutdown = "shutdown.exe -s -t 180 -f -c "&dblquote(Message)&""
set objShell = CreateObject("WScript.Shell")
objShell.Run strShutdown,0,false
intShutdown = (MsgBox("ATTENTION L'Ordinateur va s'arrêter en 3 minutes. Voulez-vous annuler l'arrêt d'ordinateur?",vbYesNo+vbExclamation+vbApplicationModal,"Cancel Shutdown"))
If intShutdown = vbYes Then
' Annuler le Shutdown
    strAbort = "shutdown.exe -a"
    set objShell = CreateObject("WScript.Shell")
    objShell.Run strAbort,0,false
End if
 
Function dblquote(strIn)
    dblquote = Chr(34) & strIn & Chr(34)
End Function
Wscript.Quit
hackoofr est actuellement connecté   Envoyer un message privé Réponse avec citation 10
Vieux 19/12/2012, 22h29   #19
hackoofr
Expert Confirmé
 
Avatar de hackoofr
 
Homme Mehdi Tounisiano
Enseignant
Inscription : juin 2009
Messages : 1 702
Détails du profil
Informations personnelles :
Nom : Homme Mehdi Tounisiano
Âge : 38
Localisation : Tunisie

Informations professionnelles :
Activité : Enseignant

Informations forums :
Inscription : juin 2009
Messages : 1 702
Points : 3 886
Points : 3 886

vous pouvez aussi chercher sur le forum comment exécuter un programme à distance avec l'outil PsExec
hackoofr est actuellement connecté   Envoyer un message privé Réponse avec citation 10
Vieux 21/12/2012, 09h44   #20
panda10b
Candidat au titre de Membre du Club
 
Homme bastien vuillemard
Administrateur systèmes et réseaux
Inscription : décembre 2012
Messages : 10
Détails du profil
Informations personnelles :
Nom : Homme bastien vuillemard
Localisation : France, Aube (Champagne Ardenne)

Informations professionnelles :
Activité : Administrateur systèmes et réseaux
Secteur : Enseignement

Informations forums :
Inscription : décembre 2012
Messages : 10
Points : 14
Points : 14
Bonjour
ça me convient très bien, je teste et reviens pour donner une réponse final
encore une fois merci de votre aide
panda10b est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse
Outils de la discussion

Navigation rapide


Fuseau horaire GMT +2. Il est actuellement 09h30.


 
 
 
 
Partenaires

Hébergement Web