This script is used to shutdown the computer while performing several task.

Download Shutdown (vbs file)

  1. ' ******************************************************** ' FILE: ShutdownScript.vbs ' VERSION: 1.1 ' CREATED: 3/21/2004 ' UPDATED:   6/28/2004 ' AUTHOR:    Scott Greenberg ' COMPANY:   SG Technology ' WEBSITE: http://gogogadgetscott.info ' DECRIPTION: ' COMMENT: N/A ' Copyright© 2004. SG Technology. All rights reserved. ' ********************************************************* Set SH = CreateObject ("WScript.Shell") Set FS = CreateObject ("Scripting.FileSystemObject") CreateSC RemoveRegKey "AIM" RemoveRegKey "TkBellExe" RemoveRegKey "NvCplDaemon" RemoveRegKey "StarSkin" ShutdownOutlook 'EmptyBin Shutdown Set Shell = Nothing Set SH = Nothing Set FS = Nothing WScript.Quit Function ScriptPath   sPath = WScript.ScriptFullName   ScriptPath = Left (sPath,InStrRev (sPath,"\")) End Function '========================================================== ' Create desktop shortcut To script '========================================================== 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.IconLocation = "explorer.exe, 0" oSC.Description = "Shutdown Computer Script" oSC.WorkingDirectory = sDesktop oSC.Save End Sub '========================================================== ' Backup Windows registry '========================================================== Sub BackupReg()   ' Needs Fix For windows XP   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 '========================================================== ' Remove unwanted startup registry key from machine And user '========================================================== Sub RemoveRegKey(sKey) sKey = "\Software\Microsoft\Windows\CurrentVersion\Run\" & sKey On Error Resume Next SH.RegDelete "HKCU" & sKey SH.RegDelete "HKLM" & sKey End Sub '========================================================== ' Empty the recycle bin '========================================================== 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   ' Delete temp file   FS.DeleteFile ScriptPath & "Tmp_EBin.vbs" End Sub '========================================================== ' Shutdown Microsoft Outlook, only needed For Outlook XP, ' As other versions will close properly at a windows ' invoked Shellutdown '========================================================== Sub ShutdownOutlook()   Set olApp = CreateObject ("Outlook.Application") olApp.Quit() Set olApp = Nothing End Sub '========================================================== ' Shutdown computer '========================================================== Sub Shutdown()   SH.Run "shutdown -s -t 1", 0, True End Sub

Download Shutdown (vbs file)