Script to Backup CPF v2.4 firewall settings

i think he means v1.1 of the scripts… well, but i am not a native english-speaker. :wink:

DOH!

If you are using Windows 2000 or Windows XP and the OS is installed in a reasonably “normal” manner, then there’s no reason why the script won’t work, unless your pathing variables aren’t standard.

You could try editing the script and changing “REGEDIT /E” to “C:\WINDOWS\REGEDIT /E”, on the proviso that your Windows OS is installed on your C: drive.

Revised script with explicit pathing is below.


[ at ] echo off
cls
echo *****************************
echo The settings are backed up to %SYSTEMDRIVE%\CPFBackup\CPFRUles.REG
echo Merge the “CPFrules.reg” file back, to restore settings
echo *****************************
echo To start press enter. To quit press the “x” button on this window
pause >nul:

cls
if not exist “%SYSTEMDRIVE%\CPFBackup” goto :new
goto :archive

:archive
echo Clearing oldest backup - please wait
del %SYSTEMDRIVE%\CPFBackup\Prior\CPFRUles.REG >nul:
echo Storing previous backup - please wait …
copy %SYSTEMDRIVE%\CPFBackup\CPFRUles.REG %SYSTEMDRIVE%\CPFBackup\Prior\CPFRUles.REG
echo Archiving current rule set - please wait …
REGEDIT /E %SYSTEMDRIVE%\CPFBackup\CPFRUles.REG “HKEY_LOCAL_MACHINE\SYSTEM\Software\Comodo\Personal Firewall”
goto :end

:new
cls
echo.
echo Creating folders - please wait …
echo.
md %SYSTEMDRIVE%\CPFBackup
md %SYSTEMDRIVE%\CPFBackup\Prior
echo Archiving registry keys - please wait …
REGEDIT /E %SYSTEMDRIVE%\CPFBackup\CPFRUles.REG “HKEY_LOCAL_MACHINE\SYSTEM\Software\Comodo\Personal Firewall”
copy %SYSTEMDRIVE%\CPFBackup\CPFRUles.REG %SYSTEMDRIVE%\CPFBackup\Prior\CPFRUles.REG >nul:
goto :end

:end
echo DONE!!!
echo Press any key to end
pause >nul:

This is the Script for “CPFBackup.zip” (Version 1.2) it uses %ALLUSERSPROFILE% IE. C:\Documents and settings\Allusers\

Code:
[ at ] echo off
cls
echo *****************************
echo The settings are backed up to %ALLUSERSPROFILE%\CPFBackup\CPFRUles.REG
echo Merge the “CPFrules.reg” file back, to restore settings
echo.
echo *** THIS IS A PRIVATE REVISION FOR A SINGLE INSTANCE BUG FIX - EB ***
echo.
echo *****************************
echo To start press enter. To quit press the “x” button on this window
pause >nul:

cls
if not exist “%ALLUSERSPROFILE%\CPFBackup” goto :new
goto :archive

:archive
echo Clearing oldest backup - please wait
del %ALLUSERSPROFILE%\CPFBackup\Prior\CPFRUles.REG >nul:
echo Storing previous backup - please wait …
copy %ALLUSERSPROFILE%\CPFBackup\CPFRUles.REG %ALLUSERSPROFILE%\CPFBackup\Prior\CPFRUles.REG
echo Archiving current rule set - please wait …
C:\WINDOWS\REGEDIT.EXE /E %ALLUSERSPROFILE%\CPFBackup\CPFRUles.REG “HKEY_LOCAL_MACHINE\SYSTEM\Software\Comodo\Personal Firewall”
goto :end

:new
cls
echo.
echo Creating folders - please wait …
echo.
md %ALLUSERSPROFILE%\CPFBackup
md %ALLUSERSPROFILE%\CPFBackup\Prior
echo Archiving registry keys - please wait …
C:\WINDOWS\REGEDIT.EXE /E %ALLUSERSPROFILE%\CPFBackup\CPFRUles.REG “HKEY_LOCAL_MACHINE\SYSTEM\Software\Comodo\Personal Firewall”
copy %ALLUSERSPROFILE%\CPFBackup\CPFRUles.REG %ALLUSERSPROFILE%\CPFBackup\Prior\CPFRUles.REG >nul:
goto :end

:end
echo DONE!!!
echo Press any key to end
pause >nul:


If this doesn’t work, do a Windows search for REGAEDIT.EXE and let us know where it is on your system.

Hope this helps,
Ewen :slight_smile:

Used v1.1 revised script in the same folder as REDEDIT.EXE and it worked :slight_smile:

it would seem that your issue is caused by the system environment variables not being set, or at least not containing the path info for c:\windows. this is worth looking into.

ewen :slight_smile:

The 1.1 backup method worked for me so far.
Want to try out some other security software, don’t I’ll be back (R)

Trend Micro IS 2007 sucks ! My notebook sure was sloooow.
So back to NOD32 and CPF (B)

But when restoring the rules (importing the .reg file). It says that it couldn’t import it all because some of the registry keys are in use ???
For Firefox I had to choose allow again, so importing didn’t work for me.
Or am I doing something wrong.

When restoring, you need to got to SECURITY - ADVANCED - MISCELLANEOUS and turn off “Protect own registry keys” before importing.

Rotty, can you add this as a note to the stickey topic. Thanks in advance.

Hope this helps,
Ewen :slight_smile:

When I used ZA I could back up my settings in My Documents each time I made some changes. This was accomplished by naming the backup and clicking a button on the overview page if I remember right. ;D A nice simple method would be best.
(B)

Yes, using a programming language such as C# or VB6 (Easier to program LOL), Delphi then a user interface would be possible. I would have to consult Panic on this as we’d have to find a language that we both have access to.

I have considered doing that i will do that if COMODO do not add it in the next version.

Also the need to close COMODO to write the settings back will be a problem that HAS to exist, otherwise if i found a way around it then i would have to tell them(I’m nice (:TNG)) and they would have to patch it (:TNG) (-: .

This is all effected by how much time we have on our hands of course.

cheers, rotty

Thanks for the help, everything imported ok now. :BNC

Ran across this tonight (err -this morning!). Worked like a charm though I did have to hard-code the environment variables, which was no problem because I wanted the backup on an external drive anyway.

Keep up the great work ya’ll! I am truely impressed at the quality of CPF! My “learning curve” merely required the flash tutorial to get moving. Well done.

Rgds.

I’m glad you have found it of use. If any more programming projects i can see that may come up with COMODO products i will have to make a thread advertising the idea and try to attract any hobiest or professional programmers into it (Depending on size, whether it is outside the spare time panic and I have.)

cheers, rotty

just tried version 1.2 and ended up wth error messages in the console, and empty folders created everywhere…well not everywhere but one called document on C, and a few others around the zip file. Are you supposed to run this file from a special folder? Anyway could anybody tell me where the cpf rules are stored in the registry. Even if the script can work, I’d like to know where cpf locates Network Rules in the registry.Thanks for your help.

I also just ran v1.2. It created the following chain of folders (within the folder I ran it from):

Users.WINDOWS/CPFBackup/Prior (Capitalizations, etc are exact to what was created).

Folder “Prior” is apparently empty.

The zipped file was unpacked, and I ran the batch file. The DOS window showed what would seem to be the proper sequence, and said it was done.

I have not installed the Beta; I have CPF v.2.3.6.81

LM

anybody knows if the backup script 1.2 works at all with cpf beta 2.4?

I’m looking into it now. Will post back shortly.

cheers,
ewen :slight_smile:

G’day,

There is a problem with the 1.2 script.

It uses the %allusersprofile% system variable, and by default, this variable is set to “C:\Documents and Settings\All Users”. Note the SPACE between the word “Documents” and the word “and”.

Due to the way CMD.EXE parses script commands, if a sequence of characters that contains one or more SPACE characters isn’t enclosed within quotation marks, CMD.EXE interprets the string UP TO THE FIRST SPACE only as a command. As the script is fed a variable which has to be substituted with the current value of the variable (C:\Documents and Settings\All Users), CMD.EXE only interprets up to the first space character.

This is why we end up with a folder in the root of dirve C: called “C:\DOCUMENTS”.

How to get around this?

The easiest way is to edit the script and replace all instances of “%ALLUSERSPROFILE%” with a location of your choice, preferably a second hard drive or a removable storage device (There’s little sense storing a backup of your firewall rules on the same hard drive).

IMHO, I would stick to V1.1 of the script. The BEST alternative is to modify V1.1 to suit your particular requirements. The scripts were developed by Rotty as a simple means of capturing and restoring the current config in the event of a reinstall wiping out the current rule/app set (as happens between major revisions).

An example of an edited V1.1 script is below. This example creates a folder in the root of drive D: called “CPFBackup” with a sub-folder called “Prior”. It has also added some text to remind users to turn off the registry protection in CPF before running the backup.

Cut and paste the code that is shown in RED into notepad (or any other text editor) and save it as a .BAT file. If using notepad, remember to change the file type from TEXT to ALL FILES. Also, remember to change the "[at] " sequence in the top line of the code to the real “at” symbol before saving.

SAMPLE CODE


@echo off
cls
echo *****************************
echo The settings are backed up to d:\CPFBackup\CPFRUles.REG
echo Merge the “CPFrules.reg” file back, to restore settings
echo *****************************
echo.
echo.
echo Before continuing, turn off registry protection in CPF.
echo.
echo This is found in SECURITY - ADVANCED - MISCELLANEOUS
echo.
echo.
echo To start press enter. To quit press the “x” button on this window
pause >nul:

cls
if not exist d:\CPFBackup goto :new
goto :archive

:archive
echo Clearing oldest backup - please wait
del d:\CPFBackup\Prior\CPFRUles.REG >nul:
echo Storing previous backup - please wait …
copy d:\CPFBackup\CPFRUles.REG d:\CPFBackup\Prior\CPFRUles.REG
echo Archiving current rule set - please wait …
REGEDIT /E d:\CPFBackup\CPFRUles.REG “HKEY_LOCAL_MACHINE\SYSTEM\Software\Comodo\Personal Firewall”
goto :end

:new
cls
echo.
echo Creating folders - please wait …
echo.
md d:\CPFBackup
md d:\CPFBackup\Prior
echo Archiving registry keys - please wait …
REGEDIT /E d:\CPFBackup\CPFRUles.REG “HKEY_LOCAL_MACHINE\SYSTEM\Software\Comodo\Personal Firewall”
copy d:\CPFBackup\CPFRUles.REG d:\CPFBackup\Prior\CPFRUles.REG >nul:
goto :end

:end
echo DONE!!!
echo Press any key to end
pause >nul:


Hope this helps, and sorry for the ■■■■■ up.

Cheers,
Ewen :slight_smile:

(:WAV)

hi Ewen!
well thanks very much for your detailed answer concerning the script. I’m gonna try this today

                                               cheers
                                               Apache

I don’t know if it will work with 2.4 beta, maybe panic can test that some time.

I don’t have a test environment, sniff.

if the registry entries are in the same place as they were with 2.3, then their SHOULD not be a problem. Since you are using the beta which usually signifies that you have a test environment, then you could test it for us if you want (-:

cheers, rotty

TNX for your time and effort, guys, to investigate and edit the script.

I changed it to send to my flash drive; it appears to have worked fine, as I now have a registry backup file on there.

Ultimately, does the destination truly matter? I mean, even if it were set to save it on the C:\ drive (assuming that to be the system drive), as long as the user knows the location, they can move the entire file off-system to another drive, CD, etc. Is that correct, or does something else factor in that would make that impossible?

Thanks again,

LM

thanks panic, I’ve jsut tried your script on the beta and it worked just fine. I got 2 identical backups, one directly under cpfbackup and a second one under a subfolder called prior…strange but it does not matter.Once again good job.

                                 cheers
                                  :■■■■