Solved

RegRead with spaces in keypath

Posted on 2010-09-16
3
1,145 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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Well hello again!  Glad to see you've made it this far without giving up.  In this, the fourth installment of my popular series, I'm going to cover functions and subroutines, what they are, and why they are useful.  Just in case you stumbled onto th…
Deploying a Microsoft Access application in a Citrix environment is not difficult but takes a few steps. However, Citrix system people are often of little help, as they typically know next to nothing about Access. The script provided here will take …
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

708 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

15 Experts available now in Live!

Get 1:1 Help Now