Hello all,
I want to share this script to download .exe from Symantec ftp:
When we install a new machine, it is installed with the last setup.exe I have. That setup.exe usually is older than current date, and I need to download the full definition from SEP Manager ou GUP. In my case, it is a problem to me because I'm using remote link, like MPLS network and that download congestion my network in business hours, and it is a big problem.
To resolve it, I got the script below from this website: http://www.computing.net/answers/programming/auto-update-virus-definitions-using-ftp-to-get-latest-file/27772.html and I made some changes for my environment, like delete files with -3 days. You need to have "forfiles" in your C:\Windows\System32, ok?
So, dont forget to change the path according your wish.
For download 64bits, you just need to change the line with *-v5i32.exe para *-v5i64.exe, therefore, create 2 .bat files, one for each platform, it is better :)
Create a task schedule in your server, for both scripts and be happy :)
Change the script extension to .bat and enjoy!!!
I was searching for exactly this and it works a treat, however, I was also looking to hopefully auto run the update after it has been downloaded.
Is this possbile and if so, what would need to be added to the script to perform the action?
Thanks!
Ok. Take a look in all REM line!
@echo off
REM Here is the path of your particular folder, ok? change it for your environment... set dir=E:\SEP\Downloads
REM Now, we can create that folder, it does not matter if not exist or exist... mkdir %dir%
REM Here, we are deleting files older than 3 days (you can move it do end of script, look there!) forfiles /P %dir% /S /M *.exe /D -3 /C "cmd /c del @path"
REM Here, we are entering in that particular folder cd %dir%
REM Here we are logging and starting the FTP just for read the files... echo Start > log32.txt date /T >> log32.txt time /T >> log32.txt if exist _.ftp32 del _.ftp32 >_.ftp32 echo open ftp.symantec.com >>_.ftp32 echo anonymous >>_.ftp32 echo anonymous >>_.ftp32 echo cd AVDEFS/symantec_antivirus_corp/ >>_.ftp32 echo bin >>_.ftp32 echo prompt >>_.ftp32 echo dir *-v5i32.exe >>_.ftp32 echo bye
REM Here we have a for to read all files in the file to determine the last file. FTP shows from older to newest, so, the last line is the newest file. REM after, it selects the last column, what is the name of the file... for /f "tokens=9" %%i in ( 'ftp -s:_.ftp32' ) do ( set file=%%i )
REM Here, we are really downloading the selected file.... and finishing logging the end! >_.ftp32 echo open ftp.symantec.com >>_.ftp32 echo anonymous >>_.ftp32 echo anonymous >>_.ftp32 echo cd AVDEFS/symantec_antivirus_corp/ >>_.ftp32 echo bin >>_.ftp32 echo prompt >>_.ftp32 echo mget %file% >>_.ftp32 echo bye echo File %file% >> log32.txt ftp -s:_.ftp32 del _.ftp32 >nul @echo. >> log32.txt echo End >> log32.txt date /T >> log32.txt time /T >> log32.txt
REM Here, you can rename your downloaded file: note that next day, you will be trying to rename a file to the same name, because you already have the file... So I recommend you to delete the oldest file, or rename it:
del %dir%\SEP_Update_x86.exe ren %dir%\%file% SEP_Update_x86.exe
REM so now, change the forfiles to here with "/D -1" option, but you deleted the file above, so, you dont need to use forfiles again, just for keep it clean in case of other .exe file, or just remove this line forfiles, ok?
forfiles /P %dir% /S /M *.exe /D -1 /C "cmd /c del @path"
exit
Dont forget to vote UP ;)
Hi,
Maybe I was not clear.
I want to save daily defs in one particular folder. Where should I use mkdir in the script?
I want it to be renamed to SEP_Update_x86 and SEP_Update_x64. Once renamed , all older defs should be deleted.
Please suggest or just add the lines as applicable and give the script :)
Much appreciated!
P.S: How exactly does the script take the latest definitions from the ftp? A little logic would help me understand as this part I just couldn't do it.
Hi raghu.mc
You can use mkdir command to create a folder. For example:
mkdir E:\SEP\Downloads\32bits (this command after set in the script)
I think you just want to create a folder to save the file, right? In this case, you dont need to check if exist, ok? just run the command mkdir
to rename the file, you just run this command below:
ren E:\SEP\Downloads\20140606i32.exe SEP_Update_x86.exe (this command before exit in the script)
Cya
Can you please assist me in setting a destination folder? I want the folder to be created if it doesn't exist.
Also, can you add a line which renames the download file to a universal name like "SEP_Update_x86"?
Would really appreciate it!
Thanks for the script.
your script is very nice
Thank you for posting....
Grt scipt dude....Thumbs up!!!!!!!!!!!!!!!!!
Hello,
Yes, it works with all versions of SEP.
No, it is just for Antivirus and Spyware.
I made some improvements, follow below:
set dir=E:\SEP\Downloads
forfiles /P %dir% /S /M *.exe /D -3 /C "cmd /c del @path" cd %dir%
echo Start > log32.txt date /T >> log32.txt time /T >> log32.txt if exist _.ftp32 del _.ftp32 >_.ftp32 echo open ftp.symantec.com >>_.ftp32 echo anonymous >>_.ftp32 echo anonymous >>_.ftp32 echo cd AVDEFS/symantec_antivirus_corp/ >>_.ftp32 echo bin >>_.ftp32 echo prompt >>_.ftp32 echo dir *-v5i32.exe >>_.ftp32 echo bye for /f "tokens=9" %%i in ( 'ftp -s:_.ftp32' ) do ( set file=%%i ) >_.ftp32 echo open ftp.symantec.com >>_.ftp32 echo anonymous >>_.ftp32 echo anonymous >>_.ftp32 echo cd AVDEFS/symantec_antivirus_corp/ >>_.ftp32 echo bin >>_.ftp32 echo prompt >>_.ftp32 echo mget %file% >>_.ftp32 echo bye echo File %file% >> log32.txt ftp -s:_.ftp32 del _.ftp32 >nul @echo. >> log32.txt echo End >> log32.txt date /T >> log32.txt time /T >> log32.txt exit
Now, you have the date/time of the script and file are running and the name of the file selected to download.
And, if you want to download 64bits version, just change whole 32 for 64 in the script.
Thank you. Would let you know once tested.
Does it work with all versions of SEP?
Would it work for the definitions like PTP and NTP?
Hi noel, nice too. But I dont have any problem with windows ftp. I suggest you to try it at home, without a firewall board.
regards!
Hi! Thank you for this script.
I could not use it, because Windows ftp.exe only works with ftp active mode. Maybe the Symantec ftp-server only supports active mode or our central firewall does not support it.
So i wrote a scipt myself with ncftp client (supports passive mode):
for /f %%i in ( 'ncftpls -F ftp://ftp.symantec.com/AVDEFS/symantec_antivirus_corp/ ^|findstr 2*-v5i32.exe' ) do ( set file=%%i ) ncftpget -F ftp://ftp.symantec.com/AVDEFS/symantec_antivirus_corp/%file%