Top 10 Useful VBScripts to Enhance Windows Experience

spyboy's avatarPosted by

VBScript, or Visual Basic Scripting, is a versatile scripting language that can be used to automate tasks, tweak system settings, and enhance the Windows experience. In this blog post, we’ll explore ten useful VBScripts that can help users streamline their workflows, troubleshoot common issues, and customize their Windows environment. Whether you’re a power user looking to optimize your system or a novice seeking to simplify everyday tasks, these scripts are sure to be valuable additions to your toolkit.

To execute this , follow these steps:

  • Open Notepad on your computer.
  • Copy and paste the above code into Notepad.
  • Save the file with a “.vbs” extension (e.g., “fakevirus.vbs”).
  • Double-click the saved file to run the script.
  1. Create System Restore Point:
strDesc = "My Restore Point"
strResult = CreateRestorePoint(strDesc, 100, 7)
If strResult = 0 Then
    MsgBox "System Restore Point created successfully.", vbInformation, "Success"
Else
    MsgBox "Failed to create System Restore Point.", vbExclamation, "Error"
End If

Function CreateRestorePoint(strDesc, intType, intEventType)
    Set objSRP = GetObject("winmgmts:\\.\root\default:Systemrestore")
    objSRP.CreateRestorePoint strDesc, intType, intEventType
    CreateRestorePoint = Err.Number
End Function

This script creates a System Restore Point with a custom description, helping users to easily revert system changes if needed.

  1. Clear Temporary Files:
Set objFSO = CreateObject("Scripting.FileSystemObject")
strTempFolder = objFSO.GetSpecialFolder(2)
Set objFolder = objFSO.GetFolder(strTempFolder)

For Each objFile In objFolder.Files
    objFile.Delete
Next

MsgBox "Temporary files cleared successfully.", vbInformation, "Success"

This script deletes temporary files from the user’s temporary folder, freeing up disk space and improving system performance.

  1. Toggle Hidden Files Visibility:
Set objShell = CreateObject("Shell.Application")
objShell.ToggleDesktop

This script toggles the visibility of hidden files and folders in Windows Explorer, making it easier for users to access hidden system files when needed.

  1. Set Default Printer:
strComputer = "."
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colInstalledPrinters = objWMIService.ExecQuery("SELECT * FROM Win32_Printer WHERE Network = FALSE")

For Each objPrinter in colInstalledPrinters
    If objPrinter.Name = "YourPrinterName" Then
        objPrinter.SetDefaultPrinter
        MsgBox "Default printer set to: " & objPrinter.Name, vbInformation, "Success"
        Exit For
    End If
Next

This script sets the default printer on the user’s system, helping users to quickly switch between multiple printers.

  1. Change Desktop Wallpaper:
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_Desktop",,48)

For Each objItem in colItems
    objItem.SetWallpaper "C:\Path\To\Your\Image.jpg"
    objItem.SetPosition 1
    MsgBox "Desktop wallpaper changed successfully.", vbInformation, "Success"
Next

This script changes the desktop wallpaper to a specified image file, allowing users to personalize their desktop environment.

  1. Disable Windows Defender:
Set objShell = CreateObject("WScript.Shell")
strCommand = "powershell.exe -Command ""Set-MpPreference -DisableRealtimeMonitoring $true"""
objShell.Run strCommand, 0, True
MsgBox "Windows Defender disabled successfully.", vbInformation, "Success"

This script disables Windows Defender real-time monitoring, useful for users who prefer to use third-party antivirus software.

  1. Backup Registry:
strBackupDir = "C:\RegistryBackups"
Set objShell = CreateObject("WScript.Shell")
strRegFile = objShell.ExpandEnvironmentStrings("%TEMP%") & "\registry_backup.reg"

strCommand = "reg export HKCU C:\RegistryBackups\HKCU_backup.reg /y"
objShell.Run strCommand, 0, True

MsgBox "Registry backup created successfully.", vbInformation, "Success"

This script exports a backup of the user’s registry keys to a specified directory, providing a safety net in case of registry errors.

  1. Toggle Windows Updates:
strComputer = "."
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_Service WHERE Name = 'wuauserv'")
For Each objItem in colItems
    If objItem.StartMode = "Auto" Then
        objItem.ChangeStartMode "Disabled"
        MsgBox "Windows Updates disabled successfully.", vbInformation, "Success"
    Else
        objItem.ChangeStartMode "Auto"
        MsgBox "Windows Updates enabled successfully.", vbInformation, "Success"
    End If
Next

This script toggles the Windows Update service between enabled and disabled states, giving users control over when updates are installed.

  1. Add Network Printer:
strComputer = "."
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set objPrinter = objWMIService.Get("Win32_Printer")
objPrinter.AddPrinterConnection "\\PrintServer\PrinterShareName"

MsgBox "Network printer added successfully.", vbInformation, "Success"

This script adds a network printer to the user’s system, simplifying the process of connecting to shared printers on the network.

  1. Display System Information:
Set objWMIService = GetObject("winmgmts:\\.\root\cimv2")
Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_OperatingSystem")

For Each objItem in colItems
    MsgBox "Operating System: " & objItem.Caption & vbCrLf & _
           "Version: " & objItem.Version & vbCrLf & _
           "Service Pack: " & objItem.ServicePackMajorVersion & "." & objItem.ServicePackMinorVersion, vbInformation, "System Information"
Next

This script retrieves and displays system information such as the operating system version and service pack, helping users troubleshoot compatibility issues and plan system upgrades.

Conclusion:
These ten VBScripts offer a range of functionality to enhance the Windows experience, from automating routine tasks to customizing system settings. Whether you’re a beginner or an advanced user, incorporating these scripts into your workflow can help you save time, optimize performance, and customize your Windows environment to suit your needs. Experiment with these scripts and discover how they can simplify your computing experience!

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.