- Dec 19, 2023
- 27
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"
2 - Paste the code below, which will be responsible for executing the necessary commands to update Kaspersky automatically when starting the system
3 - After pasting the code, save the file with whatever name you want and in a safe location with the extension .ps1 (powershell)
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:
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
️ 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"
7 - After opening the Windows task scheduler, on the right side of the window, click → "Create Task..."
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)
9 - In the "Triggers" tab, click → "New..."
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"
11 - Click on the "Actions" tab
Click "New..."
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"
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"
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.
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
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"
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)
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
️ 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"
7 - After opening the Windows task scheduler, on the right side of the window, click → "Create Task..."
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)
9 - In the "Triggers" tab, click → "New..."
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"
11 - Click on the "Actions" tab
Click "New..."
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"
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"
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.
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