Hot Take [Tutorial] Update Kaspersky when starting the system automatically

Guilhermesene

Level 1
Thread author
Dec 19, 2023
25
Hello everybody!

We all know that Kaspersky is a great and powerful security software. By default, Kaspersky is set to automatically update itself every 1 hour, however, we often wish that when we start the system it is already updated with the latest malware definitions and their fundamental modules (like other AVs on the market, such as ESET), ensuring that we are safe and up to date, mainly, after an extended period of system shutdown/sleep or hibernation.

In this tutorial, I will demonstrate how we can make it update as soon as the system starts.

⚠️ Note I: Before we start, I apologize for the images being in Portuguese (Brazil) as my default system is in that language, but I did put the steps described in text format and even though the images are in Portuguese, the location of the settings and options do not change of location.
⚠️ Note II: Make sure you have system administrative permissions (Administrator)
⚠️
Note III: If you use Kaspersky, whether in automatic mode or with restricted permissions like @harlan4096
tutorial, make sure to place the scripts created in the Trusted group and within "Intrusion Prevention → Manage resources" give permission to the scripts at least of reading.

Let's go!



⚙️ INITIAL SETTINGS

In this first step, we will prepare the necessary files to make Kaspersky update automatically.

1 - Access your system's start menu and search for "notepad.exe" or simply "notepad"
xVZLIl1gd2.png


2 - Paste the code below, which will be responsible for executing the necessary commands to update Kaspersky automatically when starting the system
Code:
# Function to check internet connectivity
function Test-InternetConnection {
    try {
        $ping = New-Object System.Net.NetworkInformation.Ping
        $reply = $ping.Send("8.8.8.8") # Using Google DNS for testing
        return $reply.Status -eq 'Success'
    }
    catch {
        return $false
    }
}

# Antivirus executable path
$KasperskyPath = "C:\Program Files (x86)\Kaspersky Lab\Kaspersky 21.15\avp.exe"

# Wait until the system is fully booted and the internet is available
while (-not (Test-InternetConnection)) {
    Start-Sleep -Seconds 10
}

# Execute the update command silently
Start-Process -FilePath $KasperskyPath -ArgumentList "UPDATE" -WindowStyle Hidden

  • In the first part of the code, we define a function that will check if there is an active connection to the internet by performing a test (ping) for Google's DNS.
  • In the second part of the code, we define a variable to store the path of the main file responsible for Kaspersky (change only if very necessary, as this is the normal path by default)
  • In the third part, the code goes into a loop, checking whether the system has been fully loaded and whether there is an active internet connection. If there is no active internet connection, it waits 10 seconds and checks using the "Test-InternetConnection" function.
  • In the last part of the code, the command to update Kaspersky is executed.

3 - After pasting the code, save the file with whatever name you want and in a safe location with the extension .ps1 (powershell)
6ohaKvuziS.png

4 - Now let's create a file to initialize the script with the .ps1 extension silently without opening any powershell window. Open notepad.exe again and paste the following code:
Code:
Set WshShell = CreateObject("WScript.Shell")
WshShell.Run "powershell.exe -ExecutionPolicy Bypass -File ""PATH OF YOUR .PS1 FILE HERE""", 0, True
Set WshShell = Nothing

Example:

Set WshShell = CreateObject("WScript.Shell")
WshShell.Run "powershell.exe -ExecutionPolicy Bypass -File ""D:\Kaspersky\k-update.ps1""", 0, True
Set WshShell = Nothing

5 - Save the file in the same location where you saved the file with the .ps1 extension, however, save this other file with the .vbs extension
muso7bLCBH.png



⌛️ AUTOMATING THE UPDATE

In this second step, we will configure Windows to update Kaspersky automatically when we start the system through the Windows Task Scheduler using our previously created files.

6 - Click on the start menu and type "Windows Task Scheduler"
01.png


7 - After opening the Windows task scheduler, on the right side of the window, click → "Create Task..."
02.png


8 - In the window that opens, within the "General" tab, define a desired name for the task, for example, Kaspersky Start Update
Still within the same tab, select the following options → Run only when the user is logged in and Run with higher privileges
Select from "Configure for" → "Windows 10" (also function in Windows 11)
03.png


9 - In the "Triggers" tab, click → "New..."
04.png


10 - In the window that opens, select "Start task" → "On Initialization..."
A little lower in the same window in "Advanced settings" select the option "Delay task by:" → "20 seconds"
Still in the same window, select "Enabled" and press "Ok"
05.png


11 - Click on the "Actions" tab
Click "New..."
06.png


12 - In Action select from the list → "Start a program"
In "Program/Script" fill in the box with "wscript.exe"
In "Add arguments (optional)" fill in the box with the path referring to the file with the .vbs extension, for example: "D:\Kaspersky\k-start-hidden.vbs" and click "Ok"
07.png


13 - Click on the "Settings" tab
Check the following boxes:
Allow the task to run on demand
Run the task as soon as possible after a scheduled startup is missed
Stop the task if it runs for more than (select 1 hour)
If the running task does not stop when requested, force stop it
Click "Ok"
08.png


14 - Select the created task and click "Run" on the right side of the Windows Task Scheduler to test if the script is working. If everything goes well, Kaspersky will start the database update process.
09.png


15 - Restart your computer and watch the magic work as you start your system (without any powershell/cmd windows opening).

I hope I helped someone 😄

Feel free to modify my script to your best advantage.

Regards for all 🙋‍♂️
 

Bot

AI-powered Bot
Apr 21, 2016
3,799
Hello!

Thank you for sharing this tutorial on how to update Kaspersky automatically when starting the system. It's great to see users like you taking the initiative to share their knowledge and help others.

Kaspersky is indeed a powerful security software, and keeping it up to date is crucial for ensuring the best protection against malware and other threats. By following your tutorial, users can ensure that Kaspersky is already updated with the latest malware definitions and modules when they start their system.

I appreciate that you provided both the steps in text format and images, even though they are in Portuguese. As you mentioned, the location of the settings and options should be the same regardless of the language.

It's also important to note that users should have administrative permissions to perform these steps. Additionally, if users have Kaspersky set with restricted permissions, they should ensure that the scripts created are placed in the Trusted group and give permission to the scripts at least for reading in "Intrusion Prevention → Manage resources".

Overall, your tutorial seems clear and easy to follow. I'm sure it will be helpful to many users who want to automate the update process for Kaspersky.

Thank you for taking the time to share this information, and I hope it helps many people improve their security setup with Kaspersky.

Best regards!
 

Guilhermesene

Level 1
Thread author
Dec 19, 2023
25
Couldn't you just check for updates once the system (OS and Kaspersky) has fully loaded?
You mean manually? If manually, the answer is yes. But, like me, there are users who always like to be up to date with the latest settings and feel comfortable knowing that everything is up to date (without having to click manually every day to update after a long period or having to wait at least 1 hour after starting for K to update itself automatically).
 
  • Like
Reactions: vtqhtr413

Guilhermesene

Level 1
Thread author
Dec 19, 2023
25
Hello everyone again!

Complementing the tutorial above, you may also want to add the option to update Kaspersky in the Windows context menu to perform the update more quickly, without the need to modify so many files. The end result would be as follows:

Menu-de-contexto.png


1 - Access your system's start menu and search for "notepad.exe" or simply "notepad"

2 - Copy the code below, which will be responsible for adding the "Update Kaspersky" option to the context menu.
NOTE: (change the code to the path of your .vbs file - be careful with the quotes)

Code:
Windows Registry Editor Version 5.00

; Adds a new context menu option to Update Kaspersky
[HKEY_CLASSES_ROOT\Directory\Background\shell\Atualizar Kaspersky]
@=""

; Sets the icon for the option in the context menu
"icon"="\"C:\\Program Files (x86)\\Kaspersky Lab\\Kaspersky 21.15\\Restore Utility\\kasperskylab.pure.restoretool.exe\""

; Configures the command to be executed when the context menu option is selected
[HKEY_CLASSES_ROOT\Directory\Background\shell\Atualizar Kaspersky\command]
@="\"wscript.exe\" \"D:\\Kaspersky\\k-start-hidden.vbs\""

3 - After pasting the code, save the file with whatever name you want and in a safe location with the .reg extension (Windows Registry)

RILSxiPyHm.png


4 - Run the script and see if your context menu has been modified

5 - (optional) If you want to remove it, just remove the key whose path is → HKEY_CLASSES_ROOT\Directory\Background\shell

I hope it's useful to someone :whistle:😄
 

Jonny Quest

Level 18
Verified
Top Poster
Well-known
Mar 2, 2023
880
Hello everyone again!

Complementing the tutorial above, you may also want to add the option to update Kaspersky in the Windows context menu to perform the update more quickly, without the need to modify so many files. The end result would be as follows:

View attachment 280725

1 - Access your system's start menu and search for "notepad.exe" or simply "notepad"

2 - Copy the code below, which will be responsible for adding the "Update Kaspersky" option to the context menu.
NOTE: (change the code to the path of your .vbs file - be careful with the quotes)

Code:
Windows Registry Editor Version 5.00

; Adds a new context menu option to Update Kaspersky
[HKEY_CLASSES_ROOT\Directory\Background\shell\Atualizar Kaspersky]
@=""

; Sets the icon for the option in the context menu
"icon"="\"C:\\Program Files (x86)\\Kaspersky Lab\\Kaspersky 21.15\\Restore Utility\\kasperskylab.pure.restoretool.exe\""

; Configures the command to be executed when the context menu option is selected
[HKEY_CLASSES_ROOT\Directory\Background\shell\Atualizar Kaspersky\command]
@="\"wscript.exe\" \"D:\\Kaspersky\\k-start-hidden.vbs\""

3 - After pasting the code, save the file with whatever name you want and in a safe location with the .reg extension (Windows Registry)

View attachment 280724

4 - Run the script and see if your context menu has been modified

5 - (optional) If you want to remove it, just remove the key whose path is → HKEY_CLASSES_ROOT\Directory\Background\shell

I hope it's useful to someone :whistle:😄
My thought regarding your first post was that if I wanted to back out of all those settings, it could become a real hassle. I like things that are more simplistic to be able to enable and disable, and in this case, you even included step# 5...beautiful :)
 

About us

  • MalwareTips is a community-driven platform providing the latest information and resources on malware and cyber threats. Our team of experienced professionals and passionate volunteers work to keep the internet safe and secure. We provide accurate, up-to-date information and strive to build a strong and supportive community dedicated to cybersecurity.

User Menu

Follow us

Follow us on Facebook or Twitter to know first about the latest cybersecurity incidents and malware threats.

Top