How to List the Boot Configuration Properties on Windows using VBScript?


On Windows, we can use VBScript to many administrative tasks. We can list the boot configuration properties of your PC using the following VBScript – which executes a SQL like query to Win32_BootConfiguration database.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
' List the Boot Configuration Properties of a Computer
Option Explicit
 
On Error Resume Next
 
Dim strComputer, colItems
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
 
Set colItems = objWMIService.ExecQuery("Select * from Win32_BootConfiguration")
 
Dim result
result = ""
For Each objItem in colItems
    result = result & "Boot Directory: " & objItem.BootDirectory
    result = result & "Configuration Path: " & objItem.ConfigurationPath
    result = result & "Description: " & objItem.Description
    result = result & "Last Drive: " & objItem.LastDrive
    result = result & "Name: " & objItem.Name
    result = result & "Scratch Directory: " & objItem.ScratchDirectory
    result = result & "Setting ID: " & objItem.SettingID
    result = result & "Temp Directory: " & objItem.TempDirectory
Next
 
WScript.Echo result
' List the Boot Configuration Properties of a Computer
Option Explicit

On Error Resume Next

Dim strComputer, colItems
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery("Select * from Win32_BootConfiguration")

Dim result
result = ""
For Each objItem in colItems
    result = result & "Boot Directory: " & objItem.BootDirectory
    result = result & "Configuration Path: " & objItem.ConfigurationPath
    result = result & "Description: " & objItem.Description
    result = result & "Last Drive: " & objItem.LastDrive
    result = result & "Name: " & objItem.Name
    result = result & "Scratch Directory: " & objItem.ScratchDirectory
    result = result & "Setting ID: " & objItem.SettingID
    result = result & "Temp Directory: " & objItem.TempDirectory
Next

WScript.Echo result

vbs-list-the-boot-configuration-properties-of-a-computer How to List the Boot Configuration Properties on Windows using VBScript? vbscript

Example output:

1
2
3
4
5
6
7
8
Boot Directory: C:\WINDOWS
Configuration Path: C:\WINDOWS
Description: \Device\Harddisk0\Partition0
Last Drive: H:
Name: BootConfiguration
Scratch Directory: C:\WINDOWS\system32\config\systemprofile\AppData\Local\Temp
Setting ID: 
Temp Directory: C:\WINDOWS\system32\config\systemprofile\AppData\Local\Temp
Boot Directory: C:\WINDOWS
Configuration Path: C:\WINDOWS
Description: \Device\Harddisk0\Partition0
Last Drive: H:
Name: BootConfiguration
Scratch Directory: C:\WINDOWS\system32\config\systemprofile\AppData\Local\Temp
Setting ID: 
Temp Directory: C:\WINDOWS\system32\config\systemprofile\AppData\Local\Temp

Is VBScript Dead?

–EOF (The Ultimate Computing & Technology Blog) —

GD Star Rating
loading...
279 words
Last Post: Teaching Kids Programming - Leaf Similar Trees by Recursive Depth First Search Algorithm
Next Post: Teaching Kids Programming - Breadth First Search Algorithm to Compute Average of Levels in Binary Tree

The Permanent URL is: How to List the Boot Configuration Properties on Windows using VBScript?

Leave a Reply