Code:
<span><span style="direction: ltr; text-align: left" class="google-src-text">Option Explicit On Error Resume Next Dim Wsh, Time1, Time2, Result, PathFile, MsgResult, MsgA, AppName, KeyA, KeyB, TimeDiff MsgA = "Fermez toutes les applications en cours et cliquez sur OK." KeyA = "HKEY_CURRENT_USER\Software\RestartTime\" KeyB = "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run\RestartTime" AppName = "Restart-Time" Set Wsh = CreateObject("WScript.Shell") PathFile = """" & WScript.ScriptFullName & """" Result = wsh.RegRead(KeyA & "Times") if Result = "" then MsgResult = Msgbox (MsgA, vbOKCancel, AppName) If MsgResult = vbcancel then WScript.Quit Wsh.RegWrite KeyA & "Times", left(Time,8), "REG_SZ" Wsh.RegWrite KeyB, PathFile, "REG_SZ" Wsh.Run "cmd /c Shutdown -r -t 00", false, 0 else Wsh.RegDelete KeyA & "Times" Wsh.RegDelete KeyA Wsh.RegDelete KeyB TimeDiff = DateDiff("s",Result,left(Time,8)) MsgBox "PC redémarré en " & TimeDiff & " secondes", VbInformation, AppName end if wscript.Quit</span> Option Explicit On Error Resume Next Sun Wsh, Time1, Time2, Result, pathfile, MsgResult, MsgA, AppName, Keya, Keyb, TimeDiff MsgA = "Close all running applications and click OK." Keya = "HKEY_CURRENT_USER \ Software \ RestartTime \ "Keyb =" HKEY_CURRENT_USER \ Software \ Microsoft \ Windows \ CurrentVersion \ Run \ RestartTime "AppName =" Restart-Time "Set Wsh = CreateObject (" WScript.Shell ") pathfile =" "" "& & WScript.ScriptFullName" "" "Result = wsh.RegRead (Keya &" Times ") if Result =" "then Msgbox MsgResult = (MsgA, vbOKCancel, AppName) If MsgResult = vbcancel Then WScript.Quit Wsh.RegWrite Keya &" Times ", left ( Time, 8), "REG_SZ" Wsh.RegWrite Keyb, pathfile, "REG_SZ" Wsh.Run "cmd / c Shutdown-r-t 00", false, 0 else Wsh.RegDelete Keya & "Times" Wsh.RegDelete Keya Wsh . RegDelete Keyb TimeDiff = DateDiff ("s", Result, Left (Time, 8)) MsgBox "PC restarted" TimeDiff & & "seconds", vbInformation, AppName end if WScript.Quit</span>
Bookmarks