Solved

RegRead with spaces in keypath

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Not long ago I saw a question in the VB Script forum that I thought would not take much time. You can read that question (Question ID  (http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_28455246.html)28455246) Here (http…
With User Account Control (UAC) enabled in Windows 7, one needs to open an elevated Command Prompt in order to run scripts under administrative privileges. Although the elevated Command Prompt accomplishes the task, the question How to run as script…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

856 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