Jump to content

Auto Fix and Defrag all drives scritpt


ezzetabi
 Share

Recommended Posts

The password, username, domain name you insert are used for login after chdsk bootime. They are not checked, and the autologon is disabled after the job.

AutoItSetOption("MustDeclareVars", 1)
Local $aDrives = DriveGetDrive ( "FIXED" )
Local $c

If Not IsAdmin() Then
   MsgBox(4096 + 16, 'Error', 'You have to be admin for using this.')
Else
   If $cmdline[0] = 0 Then
      Local $sDomain = InputBox('Domain', 'Domain name?', @computername)
      Local $sUserN  = InputBox('User', 'Username?', @username)
      Local $sPass   = InputBox('Password', 'Password?', '', '-')
      
      RegWrite('HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\Winlogon', 'AutoAdminLogon', 'REG_SZ',1)
      RegWrite('HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\Winlogon', 'DefaultDomainName', 'REG_SZ', $sDomain)
      RegWrite('HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\Winlogon', 'DefaultUserName', 'REG_SZ', $sUserN)
      RegWrite('HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\Winlogon', 'DefaultPassword', 'REG_SZ', $sPass)
      
     ;ChkDsk
      For $c = 1 to $aDrives[0] 
         RunWait(@comspec & ' /c echo y|chkdsk ' & $aDrives[$c] & ' /f /r /x', '')
      Next
      
      RegWrite('HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce', 'FixnDefrag', 'REG_SZ', '"' & @ScriptFullPath & '" /secondpart')
      Shutdown(6)
   Else
      RegWrite('HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\Winlogon', 'AutoAdminLogon', 'REG_SZ', 0)
      RegDelete('HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\Winlogon', 'DefaultPassword')
      
     ;Defrag
      For $c = 1 to $aDrives[0] 
         RunWait(@comspec & ' /c defrag ' & $aDrives[$c] & ' -f', '')
      Next
      Shutdown(13)
   EndIf
EndIf
Edited by ezzetabi
Link to comment
Share on other sites

  • 6 months later...

It runs a ChkDsk on logical partitions on the boot hard drive and on secondary hard drives. It schedules and reboots computer/server and runs a ChkDsk on boot partition during bootup. After bootup, runs Defrag on all hard drives and partitions once. After all drives have been defragged the system powers down/shuts down.

Raid setups may act differently depending on raid controller manufacturer, firmware, and model.

Edited by PerryRaptor
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...