Solved

RegRead with spaces in keypath

Posted on 2010-09-16
3
1,179 Views
Last Modified: 2012-05-10
Hey experts,

I am using RegRead in order to read a value from the registry from a VBScript. The problem is that the keypath that I am using has a key named VB and VBA Program Settings in it, obviously having spaces in it.  I keep getting the error "Invalid root in registry key". I tried my script with a keypath that did not have a space in any of the names and it worked successfully.  I have tried using literal quotes by putting """keypath""" but that still produces the same error.

Any ideas on how I can get this to work?
0
Comment
Question by:jonathan_hills
  • 2
3 Comments
 
LVL 2

Accepted Solution

by:
Procastin8or earned 500 total points
ID: 33695393
I tried reading a registry key with a blank in it using a different method and it worked. I don't if this method would work for you or not. If not, you could try setting your path to a variable and using that variable with regread.


const HKEY_LOCAL_MACHINE = &H80000002
strComputer = "."
Set StdOut = WScript.StdOut
 
Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" &_ 
strComputer & "\root\default:StdRegProv")
 
strKeyPath = "SOFTWARE\Microsoft\Windows NT\CurrentVersion\Terminal Server\Security"
strValueName = "SecurityLevel"
oReg.GetExpandedStringValue HKEY_LOCAL_MACHINE,strKeyPath,_
strValueName,strValue
 
wscript.echo  "The Windows logon UI host is: " & strValue

Open in new window

0
 
LVL 2

Expert Comment

by:Procastin8or
ID: 33695402
0
 

Author Comment

by:jonathan_hills
ID: 33695589
Thanks for the help it worked like a charm. I don't really know why mine before wasn't working, it was quite similar.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Welcome, welcome!  If you are new to the series and haven't been following along, please take a brief moment to review the first three installments: Part 1 (http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/A_266-VBScri…
I met Paul Devereux (@pdevereux) today when I responded to his tweet asking “Anybody know how to automate adding files from disk to a folder in #outlook  ?”.  I replied back and told Paul that using automation, in this case scripting, to add files t…
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

896 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now