Author Topic: Script to Backup CPF v2.4 firewall settings  (Read 160316 times)

Offline Rotty

  • Comodo's Hero
  • *****
  • Posts: 903
  • http://www.venganza.org/ - Noodly Appendage
Re: Script to Backup CPF firewall settings
« Reply #30 on: November 04, 2006, 11:05:22 PM »
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
The opinions expressed in my posts are my own. 
They do NOT necessarily represent or reflect the views of my employer.

apache255

  • Guest
Re: Script to Backup CPF firewall settings
« Reply #31 on: November 21, 2006, 04:27:08 PM »
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.

Offline Little Mac

  • Forum Volunteer
  • Global Moderator
  • Comodo's Hero
  • *****
  • Posts: 6303
  • The Colonel told me to.
Re: Script to Backup CPF firewall settings
« Reply #32 on: November 21, 2006, 05:50:33 PM »
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

These forums are focused on providing help and improvement for Comodo products.  Please treat other users with respect and make a positive contribution.  Thanks.
Forum Policy

apache255

  • Guest
Re: Script to Backup CPF firewall settings
« Reply #33 on: November 21, 2006, 06:05:21 PM »
anybody knows if the backup script 1.2 works at all with cpf beta 2.4?

Online panic

  • Global Moderator
  • Comodo's Hero
  • *****
  • Posts: 11452
  • Linux is free only if your time is worthless.;-)
Re: Script to Backup CPF firewall settings
« Reply #34 on: November 21, 2006, 08:01:02 PM »
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'm looking into it now. Will post back shortly.

cheers,
ewen :-)
As your mums would say, "If you can't play nice with all the other kiddies, go home".
All users are asked to please read and abide by the  Comodo Forum Policy.
If you can't conform, don't use the forum.

Online panic

  • Global Moderator
  • Comodo's Hero
  • *****
  • Posts: 11452
  • Linux is free only if your time is worthless.;-)
Re: Script to Backup CPF firewall settings
« Reply #35 on: November 21, 2006, 11:00:23 PM »
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

********************************************

[at]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 screw up.

Cheers,
Ewen :-)
As your mums would say, "If you can't play nice with all the other kiddies, go home".
All users are asked to please read and abide by the  Comodo Forum Policy.
If you can't conform, don't use the forum.

apache255

  • Guest
Re: Script to Backup CPF firewall settings
« Reply #36 on: November 22, 2006, 03:28:18 AM »
 (:WAV)

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

                                                   cheers
                                                   Apache

Offline Rotty

  • Comodo's Hero
  • *****
  • Posts: 903
  • http://www.venganza.org/ - Noodly Appendage
Re: Script to Backup CPF firewall settings
« Reply #37 on: November 22, 2006, 04:55:50 AM »
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
The opinions expressed in my posts are my own. 
They do NOT necessarily represent or reflect the views of my employer.

Offline Little Mac

  • Forum Volunteer
  • Global Moderator
  • Comodo's Hero
  • *****
  • Posts: 6303
  • The Colonel told me to.
Re: Script to Backup CPF firewall settings
« Reply #38 on: November 22, 2006, 11:15:51 AM »
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
These forums are focused on providing help and improvement for Comodo products.  Please treat other users with respect and make a positive contribution.  Thanks.
Forum Policy

apache255

  • Guest
Re: Script to Backup CPF firewall settings
« Reply #39 on: November 22, 2006, 11:40:01 AM »
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
                                      :Beer

Online panic

  • Global Moderator
  • Comodo's Hero
  • *****
  • Posts: 11452
  • Linux is free only if your time is worthless.;-)
Re: Script to Backup CPF firewall settings
« Reply #40 on: November 22, 2006, 03:17:21 PM »
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
                                      :Beer

The folder and the subfolder hold the current ruleset and the previous set, respectively, just to give us a better fallback postition.

cheers, and glad to hear it worked!

ewen :-)
As your mums would say, "If you can't play nice with all the other kiddies, go home".
All users are asked to please read and abide by the  Comodo Forum Policy.
If you can't conform, don't use the forum.

Online panic

  • Global Moderator
  • Comodo's Hero
  • *****
  • Posts: 11452
  • Linux is free only if your time is worthless.;-)
Re: Script to Backup CPF firewall settings
« Reply #41 on: November 22, 2006, 03:20:29 PM »
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
Does the destination matter? Yes, - the sense is storing your backups on the drive that are backing up is what??? LOL

The REG file can be transpported anywhere!

ewen :-)
As your mums would say, "If you can't play nice with all the other kiddies, go home".
All users are asked to please read and abide by the  Comodo Forum Policy.
If you can't conform, don't use the forum.

Offline Little Mac

  • Forum Volunteer
  • Global Moderator
  • Comodo's Hero
  • *****
  • Posts: 6303
  • The Colonel told me to.
Re: Script to Backup CPF firewall settings
« Reply #42 on: November 22, 2006, 05:36:09 PM »
Does the destination matter? Yes, - the sense is storing your backups on the drive that are backing up is what??? LOL

The REG file can be transpported anywhere!

ewen :-)


I guess my question was, are three different scripts for different file destinations really needed?  Why not just one script with a known save location (whatever that might be) with the statement that the user needs to move the file off-system to another drive. 

I totally get the point of not having it on the drive that's gonna crash.  I may not know much (and I am from Texas...), but I know THAT much.  Wasn't born yesterday.  ;)  LOL

LM
These forums are focused on providing help and improvement for Comodo products.  Please treat other users with respect and make a positive contribution.  Thanks.
Forum Policy

Online panic

  • Global Moderator
  • Comodo's Hero
  • *****
  • Posts: 11452
  • Linux is free only if your time is worthless.;-)
Re: Script to Backup CPF firewall settings
« Reply #43 on: November 23, 2006, 12:30:55 AM »
I guess my question was, are three different scripts for different file destinations really needed?  Why not just one script with a known save location (whatever that might be) with the statement that the user needs to move the file off-system to another drive. 

I totally get the point of not having it on the drive that's gonna crash.  I may not know much (and I am from Texas...), but I know THAT much.  Wasn't born yesterday.  ;)  LOL

LM

Rotty wrote the three versions to try and satify the differing requests he received after the wrote the first, palin vanilla one. We have added some hints on how to modify (e.g by using %1 to represent a pramater passed at the command line, etc.) but a lot of people's collective eyes glazed over when we started talking DOS. LOL

I agree, one straight forward version would be best, but its only best for those who can modify to suit their explicit needs.


Cheers LM,
Ewen :-)

As your mums would say, "If you can't play nice with all the other kiddies, go home".
All users are asked to please read and abide by the  Comodo Forum Policy.
If you can't conform, don't use the forum.

Online panic

  • Global Moderator
  • Comodo's Hero
  • *****
  • Posts: 11452
  • Linux is free only if your time is worthless.;-)
Re: Script to Backup CPF firewall settings
« Reply #44 on: November 27, 2006, 08:21:02 AM »
Hey Rotty,

Have a look at

http://forums.comodo.com/index.php/topic,4128.msg31222.html#msg31222

Your scripts been adapted to backup the Comodo Backup jobs and settings.

Thanks again,
Ewen :-)
As your mums would say, "If you can't play nice with all the other kiddies, go home".
All users are asked to please read and abide by the  Comodo Forum Policy.
If you can't conform, don't use the forum.

 

Seo4Smf 2.0 © SmfMod.Com | Smf Destek