Quite long ago I read a post in forum that a user’s hard drive becomes fragmented whenever he finished a full scan. From a logical point of view, this is possible because antivirus scans archive files and to do that, the antivirus would have to extract the files to the computer. I did a full research on all major brands of antivirus by placing a huge 2GB ZIP file with thousands of files in it and then did a full scan but couldn’t replicate the problem as there were no major fragmentation.
However I noticed another weird behavior with Kaspersky which is no matter how many times I used Defraggler to defrag the system partition, it will always end up with fragmented files even right after finishing a full disk defragmentation. Other antivirus software have no such problems and normally the analysis results shows 0 fragmented files after finished defragging. I managed to find out what is the cause of this and also how to fully defrag a computer with Kaspersky installed.
The reason for this behavior is Kaspersky has a self-defense module where it prevents any software from accessing Kaspersky files or registry. When you defrag your hard drive with the Kaspersky self-defense module enabled, the defrag application cannot access the Kaspersky folder and skips it from being defragged. For people that wants to squeeze the last ounce of performance on their computer, they will want to defrag Kaspersky too and hopefully it will perform better and faster.
Fortunately it is easy to defrag Kaspersky. First you need to disable Kaspersky Self-Defense by right clicking on the Kaspersky icon at the system tray and select Settings. Click on Options at the left pane and at the right pane, uncheck “Enable Self-Defense“. Click OK to close the Settings window. You can keep Kaspersky process running and it is not necessary to terminate Kaspersky’s process by exiting it from the system tray.

Now you can run Defraggler or any disk defragmentation tool of your choice to fully defrag your hard drive including Kaspersky. Make sure you turn on the Self-Defense option after defrag for better computer protection. Do note that whenever Kaspersky databases is updated, there will be fragmentation again.

The self-defense module is meant to protect itself from being modified or controlled by unauthorized third party application such as virus but it can be annoying as well. One of such annoyance is the inability to remote control the computer when Kaspersky interface or popup is shown.
Related posts:
I was a great fan of Kaspersky in the past until i tried some good products like Avira Personal free combining with good free firewall like comodo or Zone alarm. Kaspersky is system intensive comparing to both freewares. Now i tell every one not to use Kaspersky(both KIS and KAV) while there is more protection offered by couple of good freewares. I guess experience do makes difference like Ray said.
Raymond, you also could use Puran Defrag Free, its have Boot Time Defrag, that run before Windows.
Don’t know that what make kaspersky so valuable. even it makes problems by pop ups, disturbs users, takes lots of disk space and memory to run, not even a freeware and new problems like this also generates by him but still people love him but i m totally secured by avast free edition and never feel any security flaw with it because it updates automatically so my opinion is to leave that buggy and huge program and use avast
Expanding on Raymond’s information…
Correct
There is READ ONLY protection on the directory
I tried a simple rename of the dir from “DIRNAME” to “DIRNAME.NOT” it fails. I tried doing the simple -R-A-S-H on the dir and nothing happens. Permissions are obscured I think by LocalSystem who owns it. But frankly I am not sure. ack cruft…
You are right, I was wrong. (I admit it)
In my KIS 2009 I have two checkboxes in Settings | Options | Self Defense
Enable Self-Defense
Disable external service control
I would not only add your defrag program of choice’s executable to the Trusted Applications (make sure Do not monitor application activity is checked.), but also uncheck both self defense boxes and exit Kasper. That may fix it on it’s own.
After running the little script (in my previous post) I see the following:
AVP – (Kaspersky Internet Security) – Stopped
klbg – Kaspersky Lab Boot Guard Driver – STOPPED
KLFLTDEV – Kaspersky Lab KLFltDev (Kaspersky Lab Pnp Device Filter) – RUNNING
KLIF – Kaspersky Lab Driver (Kaspersky Lab Interceptor and Filter) – RUNNING
Klim5 – Kaspersky Anti-Virus NDIS Filter – STOPPED
klmouflt – Kaspersky Lab KLMOUFLT (Kaspersky Lab Mouse Class Filter) – STOPPED
Leaving us with these services running.
KLFLTDEV
KLIF
If we can stop these, (so far- I haven’t been able to.) I’ll bet any defrag operation will run.
It’s seems there’s no clear one size fits all solution here. Even with both Self Defence CheckBoxes un-ticked these two services are still left running.
Ultimately if nothing else works.
UNINSTALL KASPER
REBOOT
DEFRAG
INSTALL KASPER
REBOOT
A poor solution I know. But hey I am only trying to help here. Thank god, I only defrag once every couple years.
thanks ray. would be very useful once i’ve changed my antivirus to kaspersky.
@Phil: Great stuff but if I am not wrong, Kaspersky folders are still protected even if the process is terminated. You would have to stop the Kaspersky service which means you would have to go to Settings and uncheck “Disable external service control”.
@Gabethebabe: No matter how short the tip or trick that I am sharing, I always speak from experience :)
hi
typo in the title!!
“installed”
“installed” goes with two l´s.
Lot of text for a tip that will save a user like 1 seconds per year in computer performance :)
Yep yep.
Make a Batch File. avpoff.bat
-=-=-
cd C:\Program Files\Kaspersky Lab\Kaspersky Internet Security 2009
avp.com exit /password=YOURpasswordHERE
exit
-=-=-
Defrag . . Using the defrag of your choice ;o)
Restart KAV
c:\Program Files\Kaspersky Lab\Kaspersky Internet Security 2009\avp.com
These should be scripted if for anything when you play a game or something. I know the KIS 2010 has a Game mode, but KIS 2009 doesn’t which is why I script it.
If you have VB6 you can make a GUI
New Project | place two Command Buttons on a form.
Private Sub Command1_Click()
‘ Start Kasper
Shell (“c:\Program Files\Kaspersky Lab\Kaspersky Internet Security 2009\avp.com”), vbNormalFocus
End Sub
Private Sub Command2_Click()
‘ Stop Kasper
Shell (“c:\Program Files\Kaspersky Lab\avpoff.bat”), vbNormalFocus
End Sub
Compile and now you have a GUI switch to control KIS.
Good share RAY.
Hi, thank you for this interesting tip.
Try oo defrag you won’t face this problem. I tried several defrager but this one is the best.
Everyone must try it.
It’s latest version is 12 but I’ll recommend version 11….
:)
Thanks, but wouldn’t it be better to add the application to the exclusions list and select “Do not monitor application activity”? This works on both the AV and IS suites with the added bonus of not having to disable the whole thing leaving you at risk (even for only a few minutes).
Thanks Reymond for info.
I have asked in earlier post regarding yours X-Ray Project. Any update on this?
We are 100% sure that X-Ray product would be far better than Kaspersky.
:)
Please respond.
systemERROR: Defraggler uses the exact same techniques that Windows uses, so it might not be that advanced to access protected files. As for Auslogics, I’ve tested it and it can defrag protected files. I guess if everyone uses Auslogics, there is no need to disable self-defense module. Thanks for reporting.
“license verivication failed” always show if i updating kaspersky with offline way, anyone can help me?
Same problem with me, using Avast! Home 5 and Smart Defrag 1.45, I think, I should switch to Defraggler also. Thanks raymond.
Hi Raymond,I have never experienced this anomaly on my system before?
I am using Server 2008,Kaspersky Pure and Auslogics ver 3.1.0.65. I just ran a defrag using Auslogics,I had 2% fragmentation and a 0% fragmentation after. :shrugs:
good tip Ray :)
yeh, knew about this way before. Same is true for registry defragmentation or Disk cleanup.
thanks
Good tricks. I didn’t notice it. I don’t like kaspersky because I don’t update online and don’t know how to kaspersky database offline. I love Avira even online or offline update becaue small size.