Jump to content

One-Click-Backup / IE Files Deleter


Marc
 Share

Recommended Posts

To backup my system, I am using Norton Ghost 2003.

One of the goals is a small image file, so I wanted to get rid of the browser cache, the browser history, the temp files and of course the content of recycler before making the backup. In my case, the index.dat from the history folder used 6 MB valuable space...

Since Windows XP keeps all index.dat files locked all the time, the only (?) way to kill the IE-Files is at startup.

So here are two scripts: number one creates a batch file into the startup folder of the current user and reboots the computer. At startup, the batch file is run and it kills the IE-directories, invokes the second script and then kills itself.

The second script uses Norton Ghost 2003 to make the backup.

Please note that the hotkeys are only checked for the german version, most likely other languages will use other keys.

By the way, I have not been able to find a way to activate the Ghost-Window out of the system tray. But theres another way to find out (in some cases) how to invoke the desired program: call the "target" window manually and then use Process Explorer to find out what has been called and which parameters were used.

have fun

Marc

Script 1 (the IE killer)

$a = msgbox (4,"?", "Sure to clear temp files and backup the system?")
if $a=2 then exit

; kill existing clean.cmd - better safe than sorry
FileDelete(@startupdir & "\clean.cmd")

$file = FileOpen(@startupdir & "\clean.cmd", 1)

; Check if file opened for writing OK
If $file = -1 Then
    MsgBox(0, "Error", "Unable to open file.")
    Exit
EndIf

; "lokale Einstellungen" = "local settings" in english systems, IIRC
FileWriteLine($file, 'RD /S /Q "' & @UserProfileDir & '\Lokale Einstellungen\Temporary Internet Files"' & @CRLF)
FileWriteLine($file, 'RD /S /Q "' & @UserProfileDir & '\Lokale Einstellungen\Verlauf"' & @CRLF)
FileWriteLine($file, 'start "' & @ScriptDir & '\tempkill.exe"' & @CRLF)
FileWriteLine($file, "del clean.cmd" & @CRLF)
FileClose($file)

Shutdown (2)

Script 2 (Ghost Backup):

; Temp-Ordner of User-Profile
TempClear(@userprofiledir & "\Lokale Einstellungen\Temp\")

; System Temp Folder
TempClear(@TempDir)

; Empty Trashcan
FileRecycleEmpty()

sleep(5000); give the system some time to start up completely

run ('"c:\Programme\Gemeinsame Dateien\Symantec Shared\NMain.exe" /dat:c:\Programme\Symantec\Norton Ghost 2003\nswigho.nsi',"")
WinWaitActive ("Norton Ghost 2003")
Send ("s")
WinWaitActive ("Sicherungsassistent")
Send ("!w")    ; next page
Sleep (600)
send ("{DOWN}"); only Drive C:
Sleep (500)
send ("!w")    ; next page
Sleep (500)
send ("d:\" & @YEAR & @MON & @MDAY & ".gho")
Sleep (500)
send ("!w")    ; next page
Sleep (500)
send ("!w")    ; next page
Sleep (500)
send ("!j")    ; start the backup

WinWaitActive ("Norton Ghost")
Send("{ENTER}")


Func TempClear($dir)

  If Not FileExists( $Dir ) Then Return 0

; Make sure the directory has a trailing \
   If StringRight($dir, 1) <> "\" Then $dir = $dir & "\"

   Local $pattern = $dir & "*.*"
   Local $file
   Local $handle

; First delete the files in this directory
  RunWait(@ComSpec & " /c " & 'del /q /s "' & $dir & '"', "", @SW_HIDE)

; Now delete all subdirectories
; Initialize the search
   $handle = FileFindFirstFile($pattern)
   If @error Then
     MsgBox(4096, "Error", "Path not found")
   EndIf

   While 1
     $file = FileFindNextFile($handle)
     If @error Then ExitLoop
     If $file <> "." And $file <> ".." Then
       If StringInStr(FileGetAttrib($dir & $file), "D") Then
         DirRemove($dir & $file, 1)
       EndIf
     EndIf
   WEnd
; Close our search handle
   FileClose($handle)
EndFunc
Edited by Marc

Any of my own codes posted on the forum are free for use by others without any restriction of any kind. (WTFPL)

Link to comment
Share on other sites

i dunno if norton ghost does this but i know drive image does... when backing up a partition or drive that windows sits on, turn off the virtual memory, that or turn it way down, because the swap file and or page file will be backed up also.. most of the time the virtual memory files can be quite large.. i got windows 2000 backed up under 600 megs without the virtual memory file... :D

Link to comment
Share on other sites

Ghost 2003 (further versions not, afaik) is programmed to leave the swapfile and hibernation file out of the backup :D

Any of my own codes posted on the forum are free for use by others without any restriction of any kind. (WTFPL)

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...