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
| Option Explicit
Dim Titre,ws,N,Question
Titre = "Arrêt automatique de l'ordinateur"
Set ws = CreateObject("wscript.Shell")
Do
Call Choisir()
Call Poser_question()
Loop
Sub Choisir()
Do
N = Trim(InputBox("Taper le nombre de secondes avant shutdown : ",Titre,"60"))
If Not IsNumeric(N) Then
ws.Popup "Vous devez taper un Nombre !","3",Titre,0+48
End if
Loop Until IsNumeric(N)
MsgBox "Vous avez choisi " & N & " seconde(s) avant le shutdown de votre PC !",64,Titre
Run_Shutdown(N)
End Sub
Sub Poser_question()
Question = MsgBox ("Vouliez-vous annuler le shutdown de votre PC ?",VBYesNO+VbQuestion,Titre)
If Question = VbYes then
Call Annuler_Shutdown()
Wscript.Quit
else
Wscript.Quit
end if
End Sub
Sub Run_Shutdown(N)
Dim Command,Execution
Command = "Cmd /c Shutdown -s -t "& N &" -c "& DblQuote("Sauvegarder votre travail car votre PC va s'arrêter dans "& N &" seconde(s)")
Execution = ws.run(Command,0,True)
End sub
Sub Annuler_Shutdown()
Dim Command,Execution
Command = "Cmd /c Shutdown -a"
Execution = ws.run(Command,0,True)
End Sub
'*****************************************************************
'Fonction pour ajouter des guillemets dans une variable
Function DblQuote(Str)
DblQuote = Chr(34) & Str & Chr(34)
End Function
'***************************************************************** |
Partager