User Tools

Site Tools


microsoft:scripting:vbscript:scripts:expanddevicepath

Description

For expanding the DevicePath key below HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion.
An easy way to add extra driver directories to search for devices that are added to the system after install (printers, extra expansion cards, etc.).

Add ExpandDevicePathKey function calls to the bottom of the script for each driver directory relative to the SystemDrive.

Version 1

'ExpandDevicePathKey.vbs
'For expanding the DevicePath key.
'20090415, v1.
 
Set objShell = CreateObject("WScript.Shell")
 
Function ExpandDevicePathKey(strNewPath)
 
	strDevicePathValue = objShell.RegRead("HKLM\Software\Microsoft\Windows\CurrentVersion\DevicePath")
 
	If InStr(strDevicePathValue, strNewPath) = 0 Then
 
		strNewDevicePathValue = strDevicePathValue & ";%SystemDrive%\" & strNewPath
 
		objShell.RegWrite "HKLM\Software\Microsoft\Windows\CurrentVersion\DevicePath", strNewDevicePathValue, "REG_EXPAND_SZ"
 
	End If
 
End Function
 
ExpandDevicePathKey("DRV\NEW")
 
Set objShell = Nothing
microsoft/scripting/vbscript/scripts/expanddevicepath.txt · Last modified: 2012/01/15 10:27 by bas

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki