Wednesday, September 23, 2009

Create backup of pen drive and put password in the copied file

In fact making backup pen drive is quite easy, but this is an automated way

For the automation create a program that will scan for the computer name, if it is yours then it does the backup in rar or 7z or whatever compression without any password else if computer name not yours then make a backup with a password protection.

You'll need 7-zip, ScriptCryptor Compiler, quick batch compiler and notepad.

Get 7-zip and install get it, then go to "C:\program files\7-zip\" and copy the 7z.exe to your pen drive.

Get Scriptcryptor compiler and install it

Get Quick Batch Compiler and install it


Part 1 - Making backup
open notepad and copy the following codes, note that dir1, dir2 and dir3 must be replace by directories in the pen drive, I assumed there is 3 directories only

--------------------------------------------------------------------------
Codes

@echo off
7z.exe a -t7z %HOMEDRIVE%\backup.7z dir1 -bd -w
7z.exe a -t7z %HOMEDRIVE%\backup.7z dir2 -bd -w
7z.exe a -t7z %HOMEDRIVE%\backup.7z dir3 -bd -w
7z.exe a -t7z %HOMEDRIVE%\backup.7z *.* -bd -w
--------------------------------------------------------------------------
and save as first.bat

open notepad and copy the following codes with the same directory as above and replace by a password

--------------------------------------------------------------------------
Codes

@echo off
7z.exe a -t7z %HOMEDRIVE%\backup.7z dir1 -p -bd -w
7z.exe a -t7z %HOMEDRIVE%\backup.7z dir2 -p -bd -w
7z.exe a -t7z %HOMEDRIVE%\backup.7z dir3 -p -bd -w
7z.exe a -t7z %HOMEDRIVE%\backup.7z *.* -p -bd -w
--------------------------------------------------------------------------
and save as second.bat.
open quick batch compiler and compile the two batch separately. Icons can be added.

Part 2 - Check for computer name
open notepad then copy the following codes change of course and I assumed that the compiled batches are first.exe and second.exe

--------------------------------------------------------------------------
Codes

Sub Run(ByVal sFile,sParam)
Dim shell
Set shell = CreateObject("WScript.Shell")
shell.Run Chr(34) & sFile & Chr(34) & sParam, 1, false
Set shell = Nothing
End Sub

Set wshShell = WScript.CreateObject( "WScript.Shell" )
strComputerName = wshShell.ExpandEnvironmentStrings( "%COMPUTERNAME%" )
dim answer
If strComputerName = "" Then
answer = Msgbox ("Do you want to make a complete backup of the pendrive?", vbyesno + vbquestion , "Backup")
if answer = vbyes then
Run "first.exe", ""
end if
else
run "second.exe", ""
end if
--------------------------------------------------------------------------

save it as check.vbs and open scriptCryptor and open the vbs to compile it, select VBSCript in ScriptCryptor. Icon can be added. I assumed that the compiled vbs is backup.exe

Now there must be 3 executable small programs, copy them to you pendrive where the 7z.exe is found preferably in the root. directory.

now when you click on the icon backup.exe, it will ask you whether to make backup, when you click on yes, backup will be made and if it is not in your computer then a password will be set.

you can also add a menu in your pen drive and add the program backup.exe
CodySafe


the directory of output may also be change, like %windir%

No comments:

Post a Comment