By Request VBS Script To Replace A WMI String Result Set With A Substituted String

 

This VBS script was written as an example of how to replace the results from a WMI string results set to remove unwanted characters.

 

The BootDirectory value of \WINDOWS has the \ removed or trimmed from it and the Caption has the \Device\Harddisk0\Partition removed.

 

VBS Script:

 

strComputer = "LocalHost"

 

Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")

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

For Each objItem in colItems

 

strBootDirectory = Replace(objItem.BootDirectory, "\", "")

MsgBox "Boot Directory: " & strBootDirectory

 

strDisk = Replace(objItem.Caption, "\Device\Harddisk0\Partition", "")

MsgBox "Partition: " & strDisk

 

Next

 

 

Published Sunday, October 26, 2008 2:31 PM by dhite
Filed under:

Comments

No Comments