Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using VB to show a registry key value

Status
Not open for further replies.

flushie86

IS-IT--Management
Aug 11, 2004
17
0
0
US
I'm working on a script to pull 3 reg keys out and compare and replace them if necessary. The issue I'm having is getting the plane off the ground. I wanted to start by getting the script to read out a reg key but it is having issues.

so far I have this:

Option Explicit

Dim strComputer, strKeyPath, oReg, strValueName, strValue

const HKEY_CLASSES_ROOT = &H80000000
strKeyPath = "Excel.Sheet.8\shell\Open\command"
strValueName = 1
strComputer = "."
Set oReg=GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\default:StdRegProv")
WScript.Echo oReg.GetStringValue(HKEY_CLASSES_ROOT,strKeyPath,strValueName)

the reg key is the "default" so it has no name. This returns a 1 If I change the strValueName to "1" is returns a 161 it should return "C:\Program Files\Microsoft Office\Office12\EXCEL.EXE" /e "%1"

Please help!
 
>WScript.Echo oReg.GetStringValue(HKEY_CLASSES_ROOT,strKeyPath,strValueName)
[tt]
strValueName=[red]""[/red] 'for default value
dim bret 'return 0 for successful
bret=oReg.GetStringValue(HKEY_CLASSES_ROOT,strKeyPath,strValueName[red],strValue[/red])
wscript.echo bret & vbcrlf & strValueName & vbcrlf & strValue[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top