NOTE:!!! Please see the last script posting for the most up to date version of the script.

SNAPSHOT.KIX
 
I was contacted to help someone repair their system that had run an automated CHKDSK when they had rebooted their system.
Apparently the system had a corrupted system file but the entry in the Event viewer did not tell you which file and there was no data in the
.CHK file that was helpful enough to tell you what happened.
Yes there are tools out there that do this already, but thought I'd whip this up in KiXtart and WinZip to create backups that
can later be used with a difference tool to quickly locate and correct the problem.
 
This script will backup important files on your system in order to help you determine what might have changed from one point to another in order to help you more quickly repair your system in the event something were to go wrong at some point in time.
It is sort of a before and after SNAPSHOT of your system. You must have Administrative rights to fully use properly.
In order to be the most helpful it is advisable to run this daily and then burn a copy of the archive files to CD/DVD at least once per month and then delete all the old backups except the main one and start the process all over again.
 
This script requires the following software in order to function properly

KiXtart 4.23
Download KiXtart and extract KIX32.EXE and WKIX32.EXE to your C:\WINDOWS\SYSTEM32 folder so they are available via the path at all times.
 
WinZip 9.0
WinZip Command Line Support Add-On 1.1 SR-1
 
 
WinZip Command Line NOTES:
-ee = extra (enhanced deflate - smallest file)
-r = Recurse into subfolders (include subfolders). This option requires the -p or -P option.
-p|P= Store folder names. A lower case p stores only the names of folders recursed
(subfolders included) via the -r option, while an upper case P stores all folder
information specified on the command line

Example: wzzip.exe -rp Would only contain the child folder names
wzzip.exe -rP Would contain the FULL path and child folder names
 
 
Example output
  • Warning! Each run of this backup will temporarily consume up to 100MB of diskspace or more.
    Once completed the final size will be between 5 to 10MB of diskspace per run.
    After 7 days the main archive will be renamed and a new one started.
    You must decide how many versions to save and when to delete them yourself.
    Press CTRL-C now to abort, otherwise press any other key to continue...

    Backup script start time: 01:28:39

    Please wait while we record a listing of all files on the system...
    Completed recording files and saved to: C:\BACKUP_SYSTEM\2005-03-20_01.28.38_FileListing.txt
    Please wait while we export the registry to: C:\BACKUP_SYSTEM\2005-03-20_01.28.38_RegBackup.txt
    Completed export of the registry
    Please wait while we copy other important files to: C:\BACKUP_SYSTEM\

    Completed copying files to C:\BACKUP_SYSTEM\
    Please wait while we archive all the backup files in C:\BACKUP_SYSTEM\

    WinZip(R) Command Line Support Add-On Version 1.1 SR-1 (Build 6224)
    Copyright (c) WinZip Computing, Inc. 1991-2004 - All Rights Reserved

    Adding BACKUP_SYSTEM\2005-03-20_01.28.38_FileListing.txt
    Adding BACKUP_SYSTEM\2005-03-20_01.28.38_HKCU_RUN.txt
    Adding BACKUP_SYSTEM\2005-03-20_01.28.38_HKLM_RUN.txt
    Adding BACKUP_SYSTEM\2005-03-20_01.28.38_RegBackup.txt
    Adding BACKUP_SYSTEM\2005-03-20_01.28.38_boot.ini
    Adding BACKUP_SYSTEM\2005-03-20_01.28.38_system.ini
    Adding BACKUP_SYSTEM\2005-03-20_01.28.38_win.ini
    creating Zip file C:\BACKUP_SYSTEM\_SystemBackup.zip


    The backup file will be renamed once it reaches over 7 days old. Age of backup file 0

    Completed all backup routines.
    Backup script end time: 01:29:15
    Time to complete backup was: 37 seconds
    Size of backup archive file is: 6,216,712 bytes
    Press a key to continue...

 

Break On
Dim $SO,$Pause
$SO=SetOption('Explicit','On')
$SO=SetOption('NoVarsInStrings','On')
$SO=SetOption('WrapAtEOL','On')


Dim $Folder, $File, $Reg, $Age, $Start, $Finish, $OrigAge, $Attrib
$Folder='C:\BACKUP_SYSTEM\'
$File=Join(Split(@DATE,'/'),'-')+'_'+Join(Split(@TIME,':'),'.')
$Reg='_RegBackup.txt'
$Start=@TICKS
COLOR +W/R
'Warning! Each run of this backup will temporarily consume up to 100MB of diskspace or more.' ?
'Once completed the final size will be between 5 to 10MB of diskspace per run. ' ?
'After 7 days the main archive will be renamed and a new one started.' ?
'You must decide how many versions to save and when to delete them yourself.' ??
COLOR +W/B
'Backup script start time: ' + @TIME ??
If Not GetFileAttr($Folder)=16
MD $Folder
EndIf
'Please wait while we record a listing of all files on the system...' ?
SHELL '%comspec% /c DIR C:\ /S >'+$Folder+$File+'_FileListing.txt'
'Completed recording files and saved to: ' + $Folder+$File+'_FileListing.txt' ?
'Please wait while we export the registry to: ' + $Folder+$File+$Reg ?
SHELL 'regedit.exe /e ' + $Folder+$File+$Reg
SHELL 'regedit /e ' + $Folder+$File+'_HKLM_RUN.txt ' +'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run'
SHELL 'regedit /e ' + $Folder+$File+'_HKCU_RUN.txt ' +'HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run'
'Completed export of the registry' ?
'Please wait while we copy other important files to: ' + $Folder ??
COPY '%WINDIR%\win.ini' $Folder+$File+'_win.ini'
COPY '%WINDIR%\system.ini' $Folder+$File+'_system.ini'
$Attrib=SetFileAttr('C:\boot.ini',128)
COPY 'C:\boot.ini' $Folder+$File+'_boot.ini'
$Attrib=SetFileAttr('C:\boot.ini',7)
'Completed copying files to ' $Folder ?
'Please wait while we archive all the backup files in ' + $Folder ??
SHELL 'C:\PROGRA~1\WinZip\WZZIP.EXE -eerP ' + $Folder+'_SystemBackup.zip ' + $Folder+'*.txt ' +
$Folder+'*.ini'
DEL $Folder+'*.txt'
DEL $Folder+'*.ini' /c /f /h
$OrigAge=GetFileTime($Folder+'_SystemBackup.zip')
$Age=DateCalc(@DATE,SubStr(GetFileTime($Folder+'_SystemBackup.zip'),1,10))
?? 'The backup file will be renamed once it reaches over 7 days old. Age of backup file ' Color
+R/W + DateCalc(@DATE,$OrigAge,10) ??
If $Age>7
SHELL '%comspec% /c REN ' + $Folder+'_SystemBackup.zip ' + $File+'_SystemBackup.zip'
EndIf
$Finish=(@TICKS-$Start)
COLOR +W/B
'Completed all backup routines.' ?
'Backup script end time: ' + @TIME ?
'Time to complete backup was: ' + ($Finish/1000) + ' seconds' ?
'Size of backup archive file is: ' + FormatNumber(GetFileSize($Folder+'_SystemBackup.zip'),0,,,-2)
+ ' bytes' ??
COLOR +R/W
'Press any key to end...' ?
Get $Pause
Quit 1


Function DateCalc($date1, $DateOrMod, optional $SingleDigit)
Dim $_intDate1,$_intYear1,$_intMonth1,$_intDay1
Dim $_intDate2,$_intYear2,$_intMonth2,$_intDay2
$date1=Split($date1,'/')
If UBound($date1)<>2
Exit 1
EndIf
$_intYear1 = Val($date1[0])
$_intMonth1 = Val($date1[1])
$_intDay1 = Val($date1[2])
If $_intMonth1 < 3
$_intMonth1 = $_intMonth1 + 12
$_intYear1 = $_intYear1 - 1
EndIf
$_intDate1=$_intDay1+(153*$_intMonth1-457)/5+365*$_intYear1 +
$_intYear1/4-$_intYear1/100+$_intYear1/400-306
Select
Case VarType($DateOrMod)=3
$_intDate2=$_intDate1+$DateOrMod
If InStr($_intDate2,'-')$_intDate2=Val(SubStr($_intDate2,2,len($_intDate2)-1)) EndIf
$_intYear2=(100*(((100*($_intDate2+306)-25)/3652425)-(((100*($_intDate2+306)-25)/3652425)/4))
+(100*($_intDate2+306)-25))/36525
$_intMonth2=(5*(((100*($_intDate2+306)-25)/3652425)-(((100*($_intDate2+306)-25)/3652425)/4)
+($_intDate2+306)-365*$_intYear2-$_intYear2/4)+456)/153
$_intDay2=(((100*($_intDate2+306)-25)/3652425)-(((100*($_intDate2+306)-25)/3652425)/4)
+($_intDate2+306)-365*$_intYear2-$_intYear2/4)-(153*$_intMonth2-457)/5
If $_intMonth2 > 12 $_intYear2=$_intYear2+1 $_intMonth2=$_intMonth2-12 EndIf
If Not $SingleDigit
If Len($_intYear2)< 4
$_=Execute("for $i=1 to 4-len($$_intYear2) $$_intYear2 = '0' + $$_intYear2 next")
EndIf
$_intMonth2=Right("0" + $_intMonth2,2)
$_intDay2=Right("0" + $_intDay2,2)
EndIf
$DateCalc=$_intYear2+'/'+$_intMonth2+'/'+$_intDay2
Case VarType($DateOrMod)=8
$DateOrMod=Split($DateOrMod,'/')
If UBound($DateOrMod)<>2
Exit 1
EndIf
$_intYear2 = Val($DateOrMod[0])
$_intMonth2 = Val($DateOrMod[1])
$_intDay2 = Val($DateOrMod[2])
If $_intMonth2 < 3
$_intMonth2 = $_intMonth2+12
$_intYear2 = $_intYear2-1
EndIf
$_intDate2=$_intDay2+(153*$_intMonth2-457)/5+365*$_intYear2 +
$_intYear2/4-$_intYear2/100+$_intYear2/400-306
$DateCalc=$_intDate1-$_intDate2
;comment the next line if you wish to return negative results also !!!
If InStr($DateCalc,'-') $DateCalc = Val(SubStr($DateCalc,2,Len($DateCalc)-1)) EndIf
Case 1
Exit 1
EndSelect
EndFunction