Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Escape sequence in registry path

166 views
Skip to first unread message

DaveM

unread,
Aug 20, 2008, 5:08:49 PM8/20/08
to
Does anyone know how to escape a forward slash in a registry path?

This is an actual registry path and the back tick does not seem to work.

set-location
"HKLM:\System\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Ciphers\DES
56`/56"


I found some documentation that talks about WSH not supporting the use
of the slash in a registry key, but WMI does.

Does anyone know if this is also true for powershell?


Thanks for any help.

Dave M.

Gerd Schneider

unread,
Aug 21, 2008, 9:33:00 AM8/21/08
to
Hi Dave,

Escaping the forward slash / with the PS back tick will never change
anything, since from a string syntax perspective / is not a special character
that may behave differently when quoted.

Unfortunately it looks like PS does not support / in a registry key name at
all, even though / is an absolutely acceptable key name character for the
Win32 registry API. I assume this is because PS in general treats both,
forward slash and backslash, as acceptable element separator chars for any
kind of path and therefore / never can be part of any path element name.
Get-ChildItem does not even retrieve existing keys which contain a / in their
name.

I rate this as a serious flaw of the PS registry provider, but have no
workaround suggestion other than to use alternate command line registry tools.

--
Gerd

/\/\o\/\/ [MVP]

unread,
Aug 21, 2008, 10:39:01 AM8/21/08
to
I agree with Gerd,

but this might be a bit less silly as I did think :
http://thepowershellguy.com/blogs/posh/archive/2008/07/28/just-silly.aspx

this might work for editing it, do not know a workaround to create, but
might be possible using .NET directly, also :

PS HKLM:\> cd hklm:;(get-psdrive hklm).CurrentLocation =
'HKLM:\System\CurrentControlSet\Control\SecurityProvi
ders\SCHANNEL\Ciphers\DES\56`/56'
PS
HKLM:\System\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Ciphers\DES\56`/56> ls

h.t.h.
/\/\o\/\/
http://thePowerShellGuy.com

DaveM

unread,
Aug 21, 2008, 11:50:46 AM8/21/08
to
Gerd and MOW, Thanks for the confirmation.

It also looked like a flaw in the registry provider to me.

I believe I have a workaround using [Microsoft.Win32.RegistryHive]

Thanks again

DaveM

unread,
Aug 21, 2008, 1:24:29 PM8/21/08
to
The workaround in case anyone is interested.

$KeyPath =

'HKLM:\System\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Ciphers\DES

56/56'
$RegType = [Microsoft.Win32.RegistryHive]::LocalMachine
$regKey = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey($RegType,
$Env:Computername)
$regKey = $regKey.OpenSubKey($KeyPath, $TRUE)
if( -not $regKey.GetValue("Enabled")){
$regKey.SetValue("Enabled", 0, [Microsoft.Win32.RegistryValueKind]::DWord)
}
else
{
$regKey.SetValue("Enabled", 0, [Microsoft.Win32.RegistryValueKind]::DWord)
}


Thanks,

Dave M

0 new messages