Script to Backup CPF v2.4 firewall settings

NOTE: This script is provided as-is without any warranty. The makers accept no liability in the event something should go wrong or the event of data loss or any other problems.

Comodo firewall version 2.4 seems to be a little bit “dubious” with the script, we are waiting for response about what is causing the problem of the settings not being backed up properly when the firewall is NOT set to “Allow all” and are waiting for a reply. The desired backup system will be one integrated into the firewall itself which they are working on.

Panic and I have created a script that backup’s up the CPF rules to a .reg file so that people do not have to go through their registry to backup the settings.

What does everyone think about this idea.

I have 3 versions, each is explained, each works just as well, choose the one that suites what you prefer.

NOTE: When restoring, you need to go to SECURITY - ADVANCED - MISCELLANEOUS and turn off “Protect own registry keys” before importing.
You also need to set the firewall to “allow all”.
Reboot your PC!

This is the Script for “CPFBackup.zip” (Version 1.0):



 [ at ] echo off
cls
echo *****************************
echo The settings are backed up to %SYSTEMROOT%\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 "%SYSTEMROOT%\CPFBackup" goto :new
goto :archive

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

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

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


VERSION 1.5: The best of all, environment variables fixed.



 [ at ] echo off
cls
echo *****************************
echo The settings are backed up to %SYSTEMDRIVE%\Documents and Settings\%USERNAME%\DESKTOP\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%\Documents and Settings\%USERNAME%\DESKTOP\CPFBackup" goto :new
goto :archive

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

:new
cls
echo.
echo Creating folders - please wait ...
echo.
md "%SYSTEMDRIVE%\Documents and Settings\%USERNAME%\DESKTOP\CPFBackup"
md "%SYSTEMDRIVE%\Documents and Settings\%USERNAME%\DESKTOP\CPFBackup\Prior"
echo Archiving registry keys - please wait ...
REGEDIT /E "%SYSTEMDRIVE%\Documents and Settings\%USERNAME%\DESKTOP\CPFBackup\CPFRUles.REG" "HKEY_LOCAL_MACHINE\SYSTEM\Software\Comodo\Personal Firewall"
copy "%SYSTEMDRIVE%\Documents and Settings\%USERNAME%\DESKTOP\CPFBackup\CPFRUles.REG" "%SYSTEMDRIVE%\Documents and Settings\%USERNAME%\DESKTOP\CPFBackup\Prior\CPFRUles.REG" >nul:
goto :end

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


cheers, rotty

I’m adding a Swedish version of the script. / AOwL

There is now a Spanish version, courtesy of ferarg

There is now a Italian version, courtesy of pandlouk

There is now a French version, courtesy of rip_pit

[attachment deleted by admin]

Sounds great! I will test it later tonight!

Rotty and Panic,

The script looks useful for those not caring to mess directly in the Registry. It is a bit inflexible, but could be edited by anyone wanting to change the location of the archive. On the other hand, if the next version of CPF (2.4?) provides an internal mechanism for saving the settings, the script could be unnecessary, but that’s life! (:KWL)

If enough people want it, it is easy enough to vary the destination through a %X parameter that can be passed to the script at runtime. e.g. “backup g:”. If we wanted to get messy enough, the destination folder could be specified through a second parameter. Bear in mind, though, that any recovery procedure would need to use the exact parameters used to create the backup.

Also, people who don’t/can’t mess with the registry may not appreciate the inflexibility, but your point is taken.

cheers,
ewen :-0

Yes, with the update taking care of this, it may not be necessary. But who knows.

(One of the considerations in making it were that we would not use a language that requires the user to have the program installed, and cannot be edited in it’s compiled format IE. VB6, C# etc. So that the user can edit the program if they need/want to.

cheers, rotty

Rotty and Panic,

Thanks for all the work you put into this, I’ll give it a try.

marc57, did you try it, how did it go?

Trying to gauge whether people are using this, so maybe this thread can be pinned, and i can boost my ego, by having a thread in my name pinned LOL (:TNG) (:TNG) (:NRD)

cheers, rotty

Hey rotty, It worked fine for me.

The script work just fine here also!

Cool, thanks for responding.

cheers, rotty

Looks like you got a Sticky. (:KWL) It backs up fine. Just a quick question though. When restoring will the backup reg file completely overwrite the existing reg entries? I would think it completely overwrites but just want to be sure.

Thanks for this little gem! (:CLP)

Yep. Overwrites existing values in the identically named key.

Glad you like it.

cheers,
ewen :slight_smile:

OK take a deep breath… don’t know if I should admit to not knowing this but someone’s got to do it for me types who don’t know a lot.

When, why and how should we use either of these? Would it make more sense to store the file on an external drive?

All answers greatfully received. Thanks

Hey whodee,

This is used IF you want to take a backup of your firewall rules and settings. There’s no real reason to run this, but then there’s no real reason to have house insurance, is there? LOL

Definitely store the REG files on an external source as well as the default output folder. No sense having your data backup on the same drive that’s about to crash, is there?

Don’t worry about asking what you think are silly questions. The only really dumb question is the one that never gets asked.

Hope this helps,
Ewen :slight_smile:

Ewen you could regret the ‘don’t worry about silly questions’ bit.
As I see it the two two files here do the same thing, they just store the backup in different places?

What I’m not sure about (haven’t a clue about actually!) is when I’d use it. If I’m running XP and have the option to use System Restore in event of a melt down would this not restore the CPF settings as well- assuming anything was able to be rescued? I don’t have total faith in Sys Restore but it has saved me from a problems mainly with dodgy software, and the last time I had any PC problems was a few years ago now- oh no what’s that noise…

If I’d be saving the data in case of a drive failure would I not have to re-install all my software on a new drive which would have a new registery with completely different entries, etc. I’m not trying to say there is no use for it I’m just trying to find out when I would use it.

You’re right about the house insurance tho’, but ■■■■ we’ve still got it!

You’re correct about the two versions, just a change in output location.

The best reason to backup using this is if you have created custom rules and want to retain them if you have to reinstall the firewall, or if you want to have identical configurations on multiple machines. they will restore OK onto a new install because it will create any registry keys it needs if they aren’t there when its imported.

Hope this helps,
Ewen :slight_smile:

Hi,

Thanks to both of you for this script, nice idea.

However, it can’t work as is, if you are logged in with a regular account (ie. non admin) as everyone should (and even if M$ didn’t do things to make it easy). Indeed, even if you have a good FW (well, very good shall I say! :wink: ) and an equally good AV (not to say an anti-spyware), there is no exemption to run as a regular account, and that will be enforced on Vista BTW.

So, I’d suggest that the script be amended to use %ALLUSERSPROFILE%, instead of %SYSTEMROOT% or %SYSTEMDRIVE%. Indeed, in both cases, a regular user is not allowed to create a folder. OTOH, %ALLUSERSPROFILE% (usually) maps to “%SYSTEMDRIVE%\Documents and Settings\All Users” that is readable & writable by all users of your computer.
Doing so will allow any user to use the script to backup CPF settings.

OTOH, to restore settings, only an admin will have rights to restore registry settings. But backing up should be done peridocally, while restoring is only done very sporadically

Ok, i will implement what you have said, but i will send it to panic to test it, just to make sure.

Ok, made the changes and it has been tested, the original post has been updated.

Cheers, rotty

Archiving current rule set - please wait ... 'REGEDIT' is not recognized as an internal or external command, operable program or batch file. DONE!!! Press any key to end

Using v1.1 - what’s going wrong? :frowning:

Using V1.1 of what? CPF? The script is designed for V2.2 and upwards. If you are using CPF V1.1, we are sorry, but we didn’t think anyone would still be on that version.

Cheers,
Ewen :slight_smile: