Solved

RegRead with spaces in keypath

Posted on 2010-09-16
3
1,240 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Enroll in June's Course of the Month

June's Course of the Month is now available! Every 10 seconds, a consumer gets hit with ransomware. Refresh your knowledge of ransomware best practices by enrolling in this month's complimentary course for Premium Members, Team Accounts, and Qualified Experts.

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…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

691 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