This script is used to shutdown the computer while performing several task.
- Removes unwanted startup registry keys.
- Shuts down Microsoft Outlook.
- Empties the Recycle Bin.
- Creates a desktop shortcut icon to script.
Download Shutdown (vbs file)
-
-
-
-
-
-
-
-
-
-
-
-
- Set SH = CreateObject ("WScript.Shell")
- Set FS = CreateObject ("Scripting.FileSystemObject")
- CreateSC
- RemoveRegKey "AIM"
- RemoveRegKey "TkBellExe"
- RemoveRegKey "NvCplDaemon"
- RemoveRegKey "StarSkin"
- ShutdownOutlook
-
- Shutdown
- Set Shell = Nothing
- Set SH = Nothing
- Set FS = Nothing
- WScript.Quit
- Function ScriptPath
- sPath = WScript.ScriptFullName
- ScriptPath = Left (sPath,InStrRev (sPath,"\"))
- End Function
-
-
-
- Sub CreateSC()
- sDesktop = SH.SpecialFolders("Desktop")
- Set oSC = SH.CreateShortcut(sDesktop & "\ShutdownScript.lnk")
- oSC.TargetPath = WScript.ScriptFullName
- oSC.WindowStyle = 1
- oSC.Hotkey = "CTRL+ALT+D"
- oSC.IconLocation = "shell32.dll, 27"
-
- oSC.Description = "Shutdown Computer Script"
- oSC.WorkingDirectory = sDesktop
- oSC.Save
- End Sub
-
-
-
- Sub BackupReg()
-
- Const FILE_BackupReg = "backupreg.bat"
- Set fBat = FS.CreateTextFile(FILE_BackupReg, True )
- fBat.WriteLine "cd\windows"
- fBat.WriteLine "attrib -s -h -r *.dat"
- fBat.WriteLine "copy user.dat user.sav"
- fBat.WriteLine "copy system.dat system.sav"
- Set fBat = Nothing
- SH.Run FILE_BackupReg, 0, True
- End Sub
-
-
-
- Sub RemoveRegKey(sKey)
- sKey = "\Software\Microsoft\Windows\CurrentVersion\Run\" & sKey
- On Error Resume Next
- SH.RegDelete "HKCU" & sKey
- SH.RegDelete "HKLM" & sKey
- End Sub
-
-
-
- Sub EmptyBin()
- Set fEBin = FS.CreateTextFile(ScriptPath & "Tmp_EBin.vbs",2)
- fEBin.writeline "Set FS = CreateObject (""Scripting.FileSystemObject"")"
- fEBin.writeline "Set Shell = CreateObject (""Shell.Application"")"
- fEBin.writeline "Set oFolder = FS.GetFolder(""C:\RECYCLER"")"
- fEBin.writeline "If (Not oFolder Is Nothing ) Then "
- fEBin.writeline " For Each oFldr In oFolder.SubFolders"
- fEBin.writeline " Set oNS = Shell.NameSpace(oFldr.Path)"
- fEBin.writeline " If (Not oFolder Is Nothing ) Then "
- fEBin.writeline " oNS.Self.InvokeVerb(""Empty Recycle &Bin"")"
- fEBin.writeline " Set oNS = Nothing "
- fEBin.writeline " Exit For "
- fEBin.writeline " End If "
- fEBin.writeline " Next "
- fEBin.writeline " Set oFolder = Nothing "
- fEBin.writeline "End If "
- fEBin.writeline "Set FS = Nothing "
- fEBin.writeline "Set Shell = Nothing "
- fEBin.close
- iReturn = SH.Run("""" & ScriptPath & "Tmp_EBin.vbs""", 1, False )
- WScript.Sleep 650
- iReturn = SH.AppActivate("Confirm Multiple File Delete")
- If iReturn = False Then
- iReturn = SH.AppActivate("Confirm File Delete")
- End If
- If iReturn = True Then
- SH.SendKeys("{ENTER}")
- End If
-
- FS.DeleteFile ScriptPath & "Tmp_EBin.vbs"
- End Sub
-
-
-
-
-
- Sub ShutdownOutlook()
- Set olApp = CreateObject ("Outlook.Application")
- olApp.Quit()
- Set olApp = Nothing
- End Sub
-
-
-
- Sub Shutdown()
- SH.Run "shutdown -s -t 1", 0, True
- End Sub
Download Shutdown (vbs file)