Jump to content
Sign in to follow this  
Bertman

ScanShot (find drive change)

Recommended Posts

Bertman

Hey guys,

You have MSI tools of Snapshot (novell zenworks), with those tools you can make a scan of youre disk and do some changes and make a final scan. And then he will compair does scan's and you can see what happend of the disk.

@home i don't have any of does tools, so want to make a simple tool. I had made some thing, but is slow, he will scan every file. have someone any idea how to speedup ? If you' want top help me plz let me know (trebnie@hotm<nospam>.com).

What do I have:

BNSnapShot.au3

; ******************************************************
;     BNSnapShot - Nog te doen
; ******************************************************
;   1. Het proces moet VEEL sneller lopen.
;   2. Register scan.
;   3. Stoppen van een loop mbv een functie buiten de loop.
;   4. Exclude list (niet te scannen directory's/bestanden.
;   5. Gui mooi maken.
; ******************************************************


; ******************************************************
; Include's (nodige bestanden)
; ******************************************************
#include "Functions.au3"; Scan bestand
#include <GUIConstants.au3>


; ******************************************************
; Variable
; ******************************************************
 $scan_target = @WindowsDir & "\system32"


; ******************************************************
; Opbouwen van de GUI
; ******************************************************
 GUICreate("BNSnapShot", 600, 500)
 $Start_scan = GUICtrlCreateButton ("Start scan",  10, 30, 100)
 $Stoppen_scan = GUICtrlCreateButton ("Stop",  150, 30, 100)
 $Main_work = GUICtrlCreateLabel("Algemene taak",5,60,500)
 $pathlabel = GUICtrlCreateLabel("",5,75,500)
 $work = GUICtrlCreateLabel("",5,90,500)

 GUISetState ()

 While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case $msg = $Start_scan
GUICtrlSetData ($Main_work, "Begin met eerste scan")
            Before_scan($scan_target)
            MsgBox("","Afronden ?","Klik op OK als u de scan wilt afronden")
GUICtrlSetData ($Main_work,"Begin met tweede scan")
            After_scan($scan_target)
GUICtrlSetData ($Main_work,"Scans vergelijken")
            Compare()

        Case $msg = $Stoppen_scan
;~          Kijken hoe ik de loop van de scan kan onderbreken !
    EndSelect
 Wend

Functions.au3

;~ ****************************************************************
;~ *** Before scan, 1ste foto
;~ ****************************************************************
 Func Before_scan($path)
GUICtrlSetData ($work, "Verwijderen van: " & @ScriptDir & "\scan")
    DirRemove (@ScriptDir & "\scan", 1)

GUICtrlSetData ($work, "Aanmaken van: " & @ScriptDir & "\scan")
    DirCreate(@ScriptDir & "\scan")
    $outputdir = @ScriptDir & "\scan"
 
    IniWrite ($outputdir & "\info.txt", "General", "Scannen_van", $path)
    IniWrite ($outputdir & "\info.txt", "General", "Begin", @HOUR & ":" & @MIN & ":" & @SEC)
 
;~  Krijg directory informatie. ALLE DIRECTORY'S, Exclude word nu nog niet gebruikt
GUICtrlSetData ($work, "Directory structuur vinden")
    RunWait(@ComSpec & " /c dir " & $path & " /AD /B /S >""" & $outputdir & "\before_dir.txt""", "", @SW_HIDE)

    $file = FileOpen($outputdir & "\before_dir.txt", 0)

    If $file = -1 Then
        MsgBox(0, "Error", "Kan dit bestand niet vinden: " & $outputdir & "\before_dir.txt")
        Exit
    EndIf

;~ Bestanden en directory's uitzoeken
GUICtrlSetData ($work, "Bestanden en directory scannen")
    $totfiles = 0
    $totsize = 0
    While 1
        $dir = FileReadLine($file)
        If @error = -1 Then ExitLoop

        $search = FileFindFirstFile($dir & "\*.*")  
    
        If $search = -1 Then
            ContinueLoop
        EndIf

        While 1
            $file1 = FileFindNextFile($search) 
            If @error Then ExitLoop;$fout = 1
GUICtrlSetData ($pathlabel, $dir)               
                $result = StringInStr(FileGetAttrib($dir & "\" & $file1), "D")
                If $result>0 Then
;~                  Directory
GUICtrlSetData ($work, "Directory gevonden: " & $file1)
                    IniWriteSection ($outputdir & "\before_dir_info.txt", $dir & "\" & $file1,"")
                    
                    $dirinfo = DirGetSize ($dir & "\" & $file1, 1)
                    IniWrite ($outputdir & "\before_dir_info.txt", $dir & "\" & $file1, "Size", $dirinfo[0])
                    IniWrite ($outputdir & "\before_dir_info.txt", $dir & "\" & $file1, "Files", $dirinfo[1])
                    IniWrite ($outputdir & "\before_dir_info.txt", $dir & "\" & $file1, "Dir", $dirinfo[2])
                EndIf
                If $result=0 Then
;~                  Bestand
GUICtrlSetData ($work, "Bestand gevonden: " & $file1)
                    $totfiles = $totfiles + 1
                    $totsize = $totsize + FileGetSize($dir & "\" & $file1)
                    $time =  FileGetTime($dir & "\" & $file1, 1)

                    IniWrite ($outputdir & "\before_file_info.txt", $dir & "\" & $file1, "Size", FileGetSize($dir & "\" & $file1))
                    IniWrite ($outputdir & "\before_file_info.txt", $dir & "\" & $file1, "Time", $time[2] & "-" & $time[1] & "-" & $time[0] & "/" & $time[3] & ":" & $time[4] & ":" & $time[5])
                    IniWrite ($outputdir & "\before_file_info.txt", $dir & "\" & $file1, "Versie", FileGetVersion ($dir & "\" & $file1))
                EndIf
        WEnd
        FileClose($search)
    Wend
    FileClose($file)
;~  FileDelete($outputdir & "\before_dir.txt")
    
    IniWrite ($outputdir & "\info.txt", "General", "Eind", @HOUR & ":" & @MIN & ":" & @SEC)
    IniWrite ($outputdir & "\info.txt", "General", "TotFiles_before", $totfiles)
    IniWrite ($outputdir & "\info.txt", "General", "TotFilesSize_before", $totsize)
 EndFunc


;~ ****************************************************************
;~ *** After scan, laatste foto
;~ ****************************************************************
 Func After_scan($path)
    $outputdir = @ScriptDir & "\scan"
 
    IniWrite ($outputdir & "\info.txt", "General", "Scannen_van", $path)
    IniWrite ($outputdir & "\info.txt", "General", "Begin", @HOUR & ":" & @MIN & ":" & @SEC)
 
;~  Krijg directory informatie
GUICtrlSetData ($work, "Directory structuur vinden")
    RunWait(@ComSpec & " /c dir " & $path & " /AD /B /S >""" & $outputdir & "\after_dir.txt""", "", @SW_HIDE)

    $file = FileOpen($outputdir & "\after_dir.txt", 0)

    If $file = -1 Then
        MsgBox(0, "Error", "Kan dit bestand niet vinden: " & $outputdir & "\after_dir.txt")
        Exit
    EndIf

GUICtrlSetData ($work, "Bestanden en directory scannen")
    $totfiles = 0
    $totsize = 0
    While 1
        $dir = FileReadLine($file)
        If @error = -1 Then ExitLoop

        $search = FileFindFirstFile($dir & "\*.*")  
    
        If $search = -1 Then
            ContinueLoop
        EndIf

        While 1
            $file1 = FileFindNextFile($search) 
            If @error Then ExitLoop
GUICtrlSetData ($pathlabel, $dir)               
                $totfiles = $totfiles + 1
                $result = StringInStr(FileGetAttrib($dir & "\" & $file1), "D")
                If $result>0 Then
;~                  Directory
GUICtrlSetData ($work, "Directory gevonden: " & $file1)

                    IniWriteSection ($outputdir & "\after_dir_info.txt", $dir & "\" & $file1,"")
                    $dirinfo = DirGetSize ($dir & "\" & $file1, 1)
                    IniWrite ($outputdir & "\after_dir_info.txt", $dir & "\" & $file1, "Size", $dirinfo[0])
                    IniWrite ($outputdir & "\after_dir_info.txt", $dir & "\" & $file1, "Files", $dirinfo[1])
                    IniWrite ($outputdir & "\after_dir_info.txt", $dir & "\" & $file1, "Dir", $dirinfo[2])
                EndIf
                If $result=0 Then
;~                  Bestand
GUICtrlSetData ($work, "Bestand gevonden: " & $file1)
                    $totsize = $totsize + FileGetSize($dir & "\" & $file1)
                    $time =  FileGetTime($dir & "\" & $file1, 1)

                    IniWrite ($outputdir & "\after_file_info.txt", $dir & "\" & $file1, "Size", FileGetSize($dir & "\" & $file1))
                    IniWrite ($outputdir & "\after_file_info.txt", $dir & "\" & $file1, "Time", $time[2] & "-" & $time[1] & "-" & $time[0] & "/" & $time[3] & ":" & $time[4] & ":" & $time[5])
                    IniWrite ($outputdir & "\after_file_info.txt", $dir & "\" & $file1, "Versie", FileGetVersion ($dir & "\" & $file1))
                EndIf
        WEnd
        FileClose($search)
    Wend
    FileClose($file)
    FileDelete($outputdir & "\after_dir.txt")
    
    IniWrite ($outputdir & "\info.txt", "General", "Eind", @HOUR & ":" & @MIN & ":" & @SEC)
    IniWrite ($outputdir & "\info.txt", "General", "TotFiles_after", $totfiles)
    IniWrite ($outputdir & "\info.txt", "General", "TotFilesSize_after", $totsize)
 EndFunc


;~ ****************************************************************
;~ *** Compare, 1ste foto en laatste foto vergelijken !
;~ ****************************************************************
 Func Compare()
    GUICtrlSetData ($work, "")
     
    $outputdir = @ScriptDir & "\scan"
;~  Nieuwe directory !
    $var = IniReadSectionNames($outputdir & "\after_dir_info.txt")
    For $i = 1 To $var[0]
        $var1 = IniReadSection($outputdir & "\before_dir_info.txt",$var[$i])
        If $var1 = "1" Then
            FileWrite($outputdir & "\Klaar.txt", "Nieuw directory: " & $var[$i] & @CRLF)
        Else
            If IniRead($outputdir & "\after_dir_info.txt",$var[$i],"Size","BESTAADNIET") <> IniRead($outputdir & "\before_dir_info.txt",$var[$i],"Size","BESTAADNIET") Then
                FileWrite($outputdir & "\Klaar.txt", "Verandering in directory (size): " & $var[$i] & @CRLF)
            Else
                If IniRead($outputdir & "\after_dir_info.txt",$var[$i],"Files","BESTAADNIET") <> IniRead($outputdir & "\before_dir_info.txt",$var[$i],"Files","BESTAADNIET") Then
                    FileWrite($outputdir & "\Klaar.txt", "Verandering in directory (Bestanden) " & $var[$i] & @CRLF)
                Else
                    If IniRead($outputdir & "\after_dir_info.txt",$var[$i],"Dir","BESTAADNIET") <> IniRead($outputdir & "\before_dir_info.txt",$var[$i],"Dir","BESTAADNIET") Then
                        FileWrite($outputdir & "\Klaar.txt", "Verandering in directory (Directory's): " & $var[$i] & @CRLF)
                    EndIf
                EndIf               
            EndIf
        EndIf
    Next

;~  Verwijderde directory !
    $var = IniReadSectionNames($outputdir & "\before_dir_info.txt")
    For $i = 1 To $var[0]
        $var1 = IniReadSection($outputdir & "\after_dir_info.txt",$var[$i])
        If $var1 = "1" Then
            FileWrite($outputdir & "\Klaar.txt", "Verwijderd directory: " & $var[$i] & @CRLF)
        EndIf       
    Next    
    
;~  Nieuw bestand aangemaakt !
    $var = IniReadSectionNames($outputdir & "\after_file_info.txt")
    For $i = 1 To $var[0]
        $var1 = IniReadSection($outputdir & "\before_file_info.txt",$var[$i])
        If $var1 = "1" Then
            FileWrite($outputdir & "\Klaar.txt", "Nieuw bestand: " & $var[$i] & @CRLF)
        Else
            If IniRead($outputdir & "\after_file_info.txt",$var[$i],"Size","BESTAADNIET") <> IniRead($outputdir & "\before_file_info.txt",$var[$i],"Size","BESTAADNIET") Then
                FileWrite($outputdir & "\Klaar.txt", "Veranderd bestand (size): " & $var[$i] & @CRLF)
            Else
                If IniRead($outputdir & "\after_file_info.txt",$var[$i],"Versie","BESTAADNIET") <> IniRead($outputdir & "\before_file_info.txt",$var[$i],"Versie","BESTAADNIET") Then
                    FileWrite($outputdir & "\Klaar.txt", "Veranderd bestand (versie) " & $var[$i] & @CRLF)
                Else
                    If IniRead($outputdir & "\after_file_info.txt",$var[$i],"Time","BESTAADNIET") <> IniRead($outputdir & "\before_file_info.txt",$var[$i],"Time","BESTAADNIET") Then
                        FileWrite($outputdir & "\Klaar.txt", "Veranderd bestand (tijd): " & $var[$i] & @CRLF)
                    EndIf
                EndIf               
            EndIf
        EndIf
    Next
    
;~  Verwijderd bestand !
    $var = IniReadSectionNames($outputdir & "\before_file_info.txt")
    For $i = 1 To $var[0]
        $var1 = IniReadSection($outputdir & "\after_file_info.txt",$var[$i])
        If $var1 = "1" Then
            FileWrite($outputdir & "\Klaar.txt", "Verwijderd bestand: " & $var[$i] & @CRLF)
        EndIf       
    Next

;~  FileDelete($outputdir & "\before_file_info.txt")
;~  FileDelete($outputdir & "\after_file_info.txt")
    
    
    If FileExists($outputdir & "\klaar.txt") = "1" Then
        Run ("Notepad.exe " & $outputdir & "\klaar.txt")
    Else
        FileWrite($outputdir & "\Klaar.txt", "Er zijn geen veranderingen gevonden !" & @CRLF)
        Run ("Notepad.exe " & $outputdir & "\klaar.txt")
    EndIf
EndFunc

ScanDisk.rar

Share this post


Link to post
Share on other sites
jbs123

I am looking for something like this. I would be able to take a snapshot of a system and install an application and then take another snapshot to compare the difference. This looks like a good start.

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  

×