Sign in to follow this  
Followers 0
ezzetabi

Auto Fix and Defrag all drives scritpt

4 posts in this topic

#1 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites



Why don't you schedule a CHKDSK, CleanMgr, and a Defrag on each machine using the "AT" command? I have them set to run each Saturday morning.

Share this post


Link to post
Share on other sites

Could you explain a bit what this does?

E.g., if it encounters errors during Chkdsk will it reboot and schedule a ChkDsk on startup to finish fixing errors on the disk?

-Clay

MrAnalogy@gmail.com

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

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

Share this post


Link to post
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
Sign in to follow this  
Followers 0