Nitesh Pandey
asked on
Deleting Symantec files by batch files based on Windows OS edition.
Hello, for one of my customer we are facing low disk space issues on C drives. The servers are windows 2003 and 2008. We found that the virus definition files (approx of 1 GB) exits for 2 days on C drive and thus consumes approx 2 GB of space. I found below script (for windows 2008 & 2003) which deletes the definition files of one day older. I am running these steps as batch file twice (once for windows 2003 & then for windows 2008) as my the path for definition files are different.
By using batch file, is there any that the script will first determine the version on the server and then based on version it will run appropriate command section given below, something like using If\Else? I tried making the batch file script by my own but not able to create it perfectly.
# For windows 2008:
@echo on
for /F "usebackq delims==" %%I in ("servers.txt") do Call :begin %%I
goto :EOF
:begin
set srv=%1
setlocal enableextensions disabledelayedexpansion
set "where=\\%srv%\c$\ProgramD ata\Symant ec\Definit ions\Virus Defs"
for /f "skip=1 delims=" %%a in (
'dir /b /ad /tc /o-d "%where%" ^|findstr /r /c:"^[0-9]*\.[0-9]*$"'
) do rmdir /s /q "%where%\%%a"
# For windows 2003:
@echo on
for /F "usebackq delims==" %%I in ("servers.txt") do Call :begin %%I
goto :EOF
:begin
set srv=%1
setlocal enableextensions disabledelayedexpansion
set "where=\\%srv%\c$\Program Files\Common Files\Symantec Shared\VirusDefs"
for /f "skip=1 delims=" %%a in (
'dir /b /ad /tc /o-d "%where%" ^|findstr /r /c:"^[0-9]*\.[0-9]*$"'
) do rmdir /s /q "%where%\%%a"
By using batch file, is there any that the script will first determine the version on the server and then based on version it will run appropriate command section given below, something like using If\Else? I tried making the batch file script by my own but not able to create it perfectly.
# For windows 2008:
@echo on
for /F "usebackq delims==" %%I in ("servers.txt") do Call :begin %%I
goto :EOF
:begin
set srv=%1
setlocal enableextensions disabledelayedexpansion
set "where=\\%srv%\c$\ProgramD
for /f "skip=1 delims=" %%a in (
'dir /b /ad /tc /o-d "%where%" ^|findstr /r /c:"^[0-9]*\.[0-9]*$"'
) do rmdir /s /q "%where%\%%a"
# For windows 2003:
@echo on
for /F "usebackq delims==" %%I in ("servers.txt") do Call :begin %%I
goto :EOF
:begin
set srv=%1
setlocal enableextensions disabledelayedexpansion
set "where=\\%srv%\c$\Program Files\Common Files\Symantec Shared\VirusDefs"
for /f "skip=1 delims=" %%a in (
'dir /b /ad /tc /o-d "%where%" ^|findstr /r /c:"^[0-9]*\.[0-9]*$"'
) do rmdir /s /q "%where%\%%a"
I had that problem on a 2008 server and decided to move SEP & SEPM to a seperete drive so they would not impact the C drive's space. That worked perfect. We also run into the file problem as you mentioned and clear it out about once a month.
Hope this helps!
Hope this helps!
ASKER
Hi, on many of the servers we have only one drive so I have to mostly use scripting solution only. I will try to use above script tomorrow on windows servers.
ASKER
Hi oDBA, I tested above script on servers but the script checks only the first path and not the second path.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hello Mate, removing "goto :eof" helped in resolving the issue. Thank you very much for your help.
The script doesn't bother about the OS version, it just tests for both folders and deletes accordingly if one is found.
Open in new window
Edit: added online check.