Welcome, Guest. Please login or register.
October 07, 2008, 08:09:52 PM

Login with username, password and session length

197977 Posts
22785 Topics
54746 Members

Latest Member: wacek105

Search:     Advanced search | Tag Cloud
+  Welcome to the Comodo Forum
|-+  Desktop Security Products
| |-+  Comodo Firewall
| | |-+  Help for v2
| | | |-+  Script to Backup CPF v2.4 firewall settings
« previous next »
Pages: 1 2 3 [4] 5 6 ... 11 Go Down Print
Author Topic: Script to Backup CPF v2.4 firewall settings  (Read 54575 times)
Sandman
Newbie
*
Offline Offline

Posts: 12


« Reply #45 on: November 28, 2006, 12:02:18 AM »

The scripts can be fixed with a few quotation marks. This is what I did:

Quote
[ 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 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 ...
REGEDIT /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 ...
REGEDIT /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:
Logged

WinXP Pro SP3, KAV 8.0, Comodo Firewall Pro 3.0, Spyware Terminator, SuRun, Script Sentry. SpywareBlaster, SUPERAntispyware, MVPS Hosts
davitof
Newbie
*
Offline Offline

Posts: 18


« Reply #46 on: December 01, 2006, 10:38:18 AM »

I tested the script and I had a few problems with paths. I had thought the scripts included the quotes from Sandman's post, but it did not. I added the necessary double quotes. I replaced %...% by %HOMEPATH% in order to save to my home path (AllUsers should seldom be used to store data IMO). Then I created a global environment variable for the path, so that the only difference between the different versions is in line 3: just replace "set CPFB=%HOMEPATH%" with "set CPFB=%SYSTEMROOT%". I added the last exit so that the window closes automatically.

It works. At least for me!

Code:
[ at ]echo off
cls
set CPFB=%HOMEPATH%
echo *****************************
echo The settings will be backed up to %CPFB%\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 "%CPFB%\CPFBackup" goto :new

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

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

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

Frederic Da Vitoria
AOwL
Comodo SuperHero
Global Moderator
Comodo's Hero
*****
Offline Offline

Posts: 2349


Comodo Firewall Pro - Be safe, use protection...


WWW
« Reply #47 on: December 01, 2006, 12:30:07 PM »

It didn't exit by itself... Wink
Logged

WinXP SP2 HE - IE7 - FF 2 - TB - CFP 2.4 - NOD32 - BoClean -ST - AMD64x2 - 3Gb Ram - 1.5Tb HD
davitof
Newbie
*
Offline Offline

Posts: 18


« Reply #48 on: December 01, 2006, 01:51:26 PM »

Ok, my fault. The final exit is useless. I needed the exit because I ran cmd, then from inside the dos box I ran manually the batch. Then of course I would need en exit to close the dos box. Silly me. Would anyone have a smiley that slaps itself in the face?

The other mods should be ok, though. I feel the trick of using an intermediate environment variable is useful. I would have included a way to let the user choose at execution time where to put the backup, but to do this I would need XP-specific syntax (extensions to the SET command).
Logged

Frederic Da Vitoria
AOwL
Comodo SuperHero
Global Moderator
Comodo's Hero
*****
Offline Offline

Posts: 2349


Comodo Firewall Pro - Be safe, use protection...


WWW
« Reply #49 on: December 01, 2006, 02:05:25 PM »

I can chase you... dunno if I catch you...  Thinking

 Tongue                Angry
Logged

WinXP SP2 HE - IE7 - FF 2 - TB - CFP 2.4 - NOD32 - BoClean -ST - AMD64x2 - 3Gb Ram - 1.5Tb HD
panic
Global Moderator
Comodo's Hero
*****
Offline Offline

Posts: 5461


... and I say to myself, "What a wonderful world"


« Reply #50 on: December 01, 2006, 02:48:49 PM »

Ok, my fault. The final exit is useless. I needed the exit because I ran cmd, then from inside the dos box I ran manually the batch. Then of course I would need en exit to close the dos box. Silly me. Would anyone have a smiley that slaps itself in the face?

The other mods should be ok, though. I feel the trick of using an intermediate environment variable is useful. I would have included a way to let the user choose at execution time where to put the backup, but to do this I would need XP-specific syntax (extensions to the SET command).

Hey Frederic,

There's an easier way to achieve this,  rather than fiddling with the SET command.

The XP command interpreter still supports command line input parameters (%1, %2, etc.). If we assume that we always want the backup to be stored in a folder called "cpfbackup" and we only want to vary the drive that this folder is created on, if we replace all instances of "%CPFB%" with "%1" and invoke the batch file with the command "cpf_bu f:", the output of the batch file will be redirected to drive F:, or whatever we specified when invoking the batch.

There's another really handy command you can use with this (or any other) batch file - AT.

We could create another batch file that triggers the cpf_bu batch file at a predetermined time every day (or every week). A sample of this is below in red. The sample assumes that we are calling a batch file called "cpf_bu.bat" located in the root of drive C: and we want it to run at 6:41:00AM. The assumptions have been made primarily 'cause I'm too lazy to figure anything else out. LOL. you'll need to remember to replace the  "[ at ]" with the real at symbol (as opposed to the at command).

Now I don't know where I'm at. LOL

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

[ at ] echo off
at 6:41:00 c:\cpf_bu.bat


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

We unfortunately can't combine the "at" command with the input variable, as it seems to cease parsing at the filename, so we would need to pre-modify the batch file to contain the required destination path.

To have this run the CPF backup every day, include the above line in a batch file and place the batch file in STARTUP, win.ini (XP will still read this) or somewhere that is autoexecuted on system startup.

If you are going to run this to autobackup the rulesets, I'd modify the cpf_bu.bat script to make a further iteration  (current - prior - oldest). This is just in case the rulesets get stuffed up and we have overwritten our good rules. Next time we boot, out good prior rulesset woudl be overwritten and wehave no way back. With a third iteration, we've at least got one reboot to move the good backup out of the way. Just a thought.

Hope this helps,
Ewen :-)
« Last Edit: December 01, 2006, 03:05:08 PM by panic » Logged

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 don't like it, don't use the forum.
davitof
Newbie
*
Offline Offline

Posts: 18


« Reply #51 on: December 01, 2006, 04:12:15 PM »

I don't know why, I felt that using command line parameters wasn't a good idea. But you are right, since the parameters could be hard coded in the shortcut, your way of doing it is simpler. But we'd still have to document the fact that the destination can include environment paths such as HOMEPATH.
Logged

Frederic Da Vitoria
Rotty
Global Moderator
Comodo's Hero
*****
Offline Offline

Posts: 793

http://www.venganza.org/ - Noodly Appendage


« Reply #52 on: December 01, 2006, 07:32:44 PM »

If anyone wants the script updated, i can edit my original post.

Admins are welcome to up date my first post if necessary (-: .  I will have differing amounts of work over the next 3 years so i may not visit for a week or two occasionally.

Learning C++ to, may port this program to C++ if it turns out to be a good language for the aim of this program and if COMODO have not implemented the scripts functionality into the program.

Make it really shine, have proper archiving, could put an auto run/ scheduling feature in and all sorts of stuff.  I don't program Batch for work or learning so hence anything new to be added has to be researched and learnt then to use a language that i know and are using in other areas anyway.

cheers, rotty
Logged

The opinions expressed in my posts are my own. 
They do NOT necessarily represent or reflect the views of my employer.
davitof
Newbie
*
Offline Offline

Posts: 18


« Reply #53 on: December 03, 2006, 06:58:32 AM »

Porting it to C++ or any other compiled language would not be a good idea IMO (except as a way to learn how to do it).

First of all, I think you have more chances to find users able to understand a DOS batch than a c++ source (at least in the Windows world). I don't think you would have got so many corrections as you got here if you had originally posted your tool in c++.

Second, a 3rd generation language implies a compiler to deploy any correction or evolution. Not everybody has a compiler and knows how to use it.

Third, if someone posted a new compliation supposedly with corrections or new features, it would imply taking measures to ensure this new version isn't actually a trojan or doesn't contain a virus.

And fourth, this kind of feature should be directly included in CPF, the external tool is only a temporary solution until then.

OTOH, using a more evolved language would allow more user-friendly features. I don't know enough VBscript, but maybe it could be done with it...
Logged

Frederic Da Vitoria
AOwL
Comodo SuperHero
Global Moderator
Comodo's Hero
*****
Offline Offline

Posts: 2349


Comodo Firewall Pro - Be safe, use protection...


WWW
« Reply #54 on: December 03, 2006, 07:24:33 AM »

Hopefully Comodo will put in a save settings option VERY soon... Grin
Logged

WinXP SP2 HE - IE7 - FF 2 - TB - CFP 2.4 - NOD32 - BoClean -ST - AMD64x2 - 3Gb Ram - 1.5Tb HD
Rotty
Global Moderator
Comodo's Hero
*****
Offline Offline

Posts: 793

http://www.venganza.org/ - Noodly Appendage


« Reply #55 on: December 07, 2006, 06:20:40 PM »

davitef:  Yes you named the main reasons why we choose batch files instead of any compiled programming language.

Turns out I'm not learning c++ anyway (-:

I would NEVER put a virus in something i write, the main reason being that to test it i would have to run it on my own PC  Tongue .  And secondly morally wrong.  And thirdly i have no imaging software  Tongue.  Fourthly i don't have time and could not be bothered (Got better things to do).

regards, rotty
Logged

The opinions expressed in my posts are my own. 
They do NOT necessarily represent or reflect the views of my employer.
MFB
Newbie
*
Offline Offline

Posts: 6


« Reply #56 on: December 07, 2006, 09:45:10 PM »

I know question is pretty lame. My dos knowledge about making scripts is close to zero. 

How do I copy and paste the code posted to make a executable? 

Logged
panic
Global Moderator
Comodo's Hero
*****
Offline Offline

Posts: 5461


... and I say to myself, "What a wonderful world"


« Reply #57 on: December 07, 2006, 10:42:50 PM »

I know question is pretty lame. My dos knowledge about making scripts is close to zero. 

How do I copy and paste the code posted to make a executable? 



It's only scary the first time!

1. Highlight the code and press CTRL-C to copy it to the clipboard.
2. Open NOTEPAD
3. With Notepad open, click inside the notepad window and press CTRL-V to paste the copied code.
4. Make whatever modifications you want to suit your environment.
5. Click FILE - SAVE AS
6. Change the "Save as type" to "All files"
7. Give your script file a name and make sure it ends in".BAT" (Note the full stop before the B-A-T).

Congrats, you have just saved your first batch file.

Hope this helps,
Ewen :-)
Logged

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 don't like it, don't use the forum.
davitof
Newbie
*
Offline Offline

Posts: 18


« Reply #58 on: December 08, 2006, 03:13:10 AM »

Rotty:

Sorry, I was not clear enough, I did not mean you would voluntarily put a virus. Once you post an executable, someone else will post an evolution and somewhere in the chain of posts someone might post (voluntarily or not) a contaminated version.

Remember that you may very well be unaware that you are hosting a virus (even if you have a good and up to date anti virus). Virus almost always have incubation periods during which they only disseminate and contaminate other systems without doing any harm (just like biological viruses do). So your system (or mine or the system of any other subscirber) may very well harbor an unknown yet malware.
Logged

Frederic Da Vitoria
davitof
Newbie
*
Offline Offline

Posts: 18


« Reply #59 on: December 08, 2006, 03:22:07 AM »

MFB:

Actually, I'd advise you to download using one of the links below the original post. Here is why: This comodo forum automatically transforms some characters. So that the first line of the script has been changed (I think this is the only modification). This modification doesn't change results of the script, only it's visual behaviour. If you decide to copy-paste the script, you should replace [ at ] with the at sign (the one that is used in e-mail addresses). You should remove the folowing space too so that the at sign is immediately followed by echo off, like in the following example (except that I used a dollar sign instead of the at sign):
$echo off
Logged

Frederic Da Vitoria
Tags:
Pages: 1 2 3 [4] 5 6 ... 11 Go Up Print 
« previous next »
Jump to:  

SSL Firewall
Page created in 0.334 seconds with 20 queries.
Powered by SMF 1.1.5 | SMF © 2006, Simple Machines LLC
Seo4Smf v0.2 © Webmaster's Talks
Design by 7dana.com