Hi From the News
Page 10
Index Page 9 | Page 11 | Nomenclature

      defragShutDown.bat  -- Defrags and shuts down automatically.
                 Notice:     The latest version is not the following code
                             but is in the below ZIP file, defragShutDown
                             VBS (currently ver5.2), download.

                             If Norton AntiVirus find it suspicious, then
                             take a look after an option named Authorize.



@ echo off %[ Written defragShutDown.bat in 44 lines and 1900 bytes ]%
@ if exist %0.bat %0.bat
@ find.exe<%0 /v "@ ">%temp%.\defragShutDown.vbs
@ for %%C in (echo pause) do %%C. Do NOT work but close programs, then
@ start wScript.exe %temp%.\defragShutDown.vbs
@ for %%C in (cls exit) do %%C
  wScript.createObject("wScript.shell").run"%ComSpec% /CDel ""%temp%"_
  & ".\defragShutDown.vbs""", 0
dim obj, oEx, OS, defrag, drive
on error resume next
drive= left(inputBox("What Drive Letter?", "Defrag", "C"), 1)
set obj= wScript.createObject("wScript.shell")
OS= obj.expandEnvironmentStrings("%OS%")
if OS="Windows_NT" then
  defrag= obj.expandEnvironmentStrings("%SystemRoot%")&_
          "\System32\defrag.exe "& drive & ": -f"
else OS= "Win9X"
  defrag= "start.exe /max /wait "& obj.expandEnvironmentStrings _
          ("%winDir%")& mid("\defrag.exe "& drive & ":",len(drive),14)
end if
set oEx= obj.exec(defrag)
if err = (oEx.status=1)+0 and OS = "Win9X" then wScript.sleep(1625): _
                          obj.appActivate"defrag": obj.sendKeys"{tab}"
if err=0 then
  do while oEx.status = 0
     if OS = "Win9X" then
         for c=0 to 96:wScript.sleep 625:if oEx.status=1 then exit for
         next'[ User may quit, so a minute at intervals of .625 sec ].
         if oEx.status=0 then obj.appActivate"defrag": obj.sendKeys"~"
         wScript.sleep 220
         if oEx.status=0 then obj.appActivate"defrag": obj.sendKeys"~"
     end if
end if
'[ It may take 60 sec or less before the Counting Down Menu appears ]:
if 7<>obj.popUp("Shut down computer?", 10, "Turn off power?", 36) then
  if OS = "Win9X" then
     obj.run "%winDir%\runDll32.exe user.exe,ExitWindows"
           getSpecialFolder(1) & "\shutdown.exe -s -t 0")
  end if
end if
set obj= nothing: set oEx= obj


If you programming this modification, you'll end up with 47 lines. Do:

Substitute line number one with the following line:
@ echo off %[ Version3 ]%
and then
line numb 11 (drive= left)... could be substituted with the following:

drive= left(inputBox("Defrag What Drive?", createObject("scripting."&_
"fileSystemObject").getDrive("C:").volumeName & " (C:) Free space: "&_
":").freeSpace,0) & " bytes", "C"), 1)

@ echo off %[ Version4 ]% :' Delete line numb 40 and 41 (if Version3, line numb 43 and 44): obj.run(createObject("scripting.fileSystemObject")._ getSpecialFolder(1) & "\shutdown.exe -s -t 0") :' Use the following 4 lines, instead: For Each objOS in _ GetObject("winmgmts:{(Shutdown)}").ExecQuery("Select * from " & _ "Win32_OperatingSystem"): objOS.Win32Shutdown(1) Next

   The UseNet
   defragShutDown.zip defragShutDown.vbs (Version5.2)


-Top- Page 9 | Page 11 | Nomenclature