Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > PowerShell

Vista - How can I escape a slash character in item name?

Reply
 
Old 03-14-2007   #1 (permalink)
KH.Lee


 
 

How can I escape a slash character in item name?

I have a problem with my powershell.
When I execute a command like this:

gi "HKLM:\SOFTWARE\Classes\AutoProxyTypes\Application/x-internet-signup"

an error occurr like this:

Get-Item : Cannot find path

'HKEY_LOCAL_MACHINE\SOFTWARE\Classes\AutoProxyTypes\Application\x-internet-signup'
because
it does not exist.
At line:1 char:3
+ gi <<<<
"HKLM:\SOFTWARE\Classes\AutoProxyTypes\Application/x-internet-signup"

How can I solve this problem in my powershell?

My System SpecsSystem Spec
Old 03-14-2007   #2 (permalink)
Brandon Shell


 
 

Re: How can I escape a slash character in item name?

Backtick "`" is the escape character, but for what your doing I don't see the need.

Maybe its a language pack issue, but
gi "HKLM:SOFTWARE\Classes\AutoProxyTypes\Application\x-internet-signup"
should just work.

--
Brandon Shell
---------------
Stop by my blog some time
Blog: http://www.bsonposh.com/
PSH Scripts Project: www.codeplex.com/psobject
--------------------------------------

"KH.Lee" <redjade.lee@gmail.com> wrote in message news:Ojq5ZXhZHHA.4368@TK2MSFTNGP06.phx.gbl...
>I have a problem with my powershell.
> When I execute a command like this:
>
> gi "HKLM:\SOFTWARE\Classes\AutoProxyTypes\Application/x-internet-signup"
>
> an error occurr like this:
>
> Get-Item : Cannot find path
>
> 'HKEY_LOCAL_MACHINE\SOFTWARE\Classes\AutoProxyTypes\Application\x-internet-signup'
> because
> it does not exist.
> At line:1 char:3
> + gi <<<<
> "HKLM:\SOFTWARE\Classes\AutoProxyTypes\Application/x-internet-signup"
>
> How can I solve this problem in my powershell?

My System SpecsSystem Spec
Old 03-14-2007   #3 (permalink)
KH.Lee


 
 

Re: How can I escape a slash character in item name?

Thank for your answer ^^

Sorry, but I already know that the Backtick "`" is the escape character.

In the filesystem, there is no way to use the slash "/" character in the
name of the file and directory.

But, in the registry, it is possible to use the slash "/" character in
the key name. For example,
"HKEY_LOCAL_MACHINE\SOFTWARE\Classes\MIME\Database\Content Type" key
contains following subkeys.

--------------------------------------------------------------------
cmd /c reg query
"HKEY_LOCAL_MACHINE\SOFTWARE\Classes\MIME\Database\Content Type"
--------------------------------------------------------------------
application/atom+xml
application/fractals
application/futuresplash
application/haansofthwp
application/hta
....
--------------------------------------------------------------------
and they contains a "/" character in their's name.

Simply...

gci -r "HKLM:\SOFTWARE\Classes\mime\Database\Codepage"

This is works fine ... But,

gci -r "HKLM:\SOFTWARE\Classes\mime\Database\Content Type"

this is not works,

How can I list all the subkeys?

Thanks.


Brandon Shell ¾´ ±Û:
> Backtick "`" is the escape character, but for what your doing I don't
> see the need.
>
> Maybe its a language pack issue, but
> gi "HKLM:SOFTWARE\Classes\AutoProxyTypes\Application\x-internet-signup"
> should just work.
>
> --
> Brandon Shell
> ---------------
> Stop by my blog some time
> Blog: http://www.bsonposh.com/
> PSH Scripts Project: www.codeplex.com/psobject
> <http://www.codeplex.com/psobject>
> --------------------------------------
> "KH.Lee" <redjade.lee@gmail.com <mailto:redjade.lee@gmail.com>> wrote in
> message news:Ojq5ZXhZHHA.4368@TK2MSFTNGP06.phx.gbl...
> >I have a problem with my powershell.
> > When I execute a command like this:
> >
> > gi "HKLM:\SOFTWARE\Classes\AutoProxyTypes\Application/x-internet-signup"
> >
> > an error occurr like this:
> >
> > Get-Item : Cannot find path
> >
> >

> 'HKEY_LOCAL_MACHINE\SOFTWARE\Classes\AutoProxyTypes\Application\x-internet-signup'
> > because
> > it does not exist.
> > At line:1 char:3
> > + gi <<<<
> > "HKLM:\SOFTWARE\Classes\AutoProxyTypes\Application/x-internet-signup"
> >
> > How can I solve this problem in my powershell?

My System SpecsSystem Spec
Old 03-14-2007   #4 (permalink)
Brandon Shell


 
 

Re: How can I escape a slash character in item name?

I see what you mean. I think that is a bug in Get-ChildItem.

This will work (did for me)
$key = gi HKLM:\SOFTWARE\Classes\mime\Database\Content Type
$key.GetSubKeyNames()

You can also do
$key.OpenSubKey("$subkeyName")
like
$key.OpenSubKey("video/x-mpeg")

if you want all the subkeys you can do
$key = gi HKLM:\SOFTWARE\Classes\mime\Database\Content Type
foreach($sub in $key.GetSubKeyNames())
{
$key.OpenSubKey($sub)
}
--

"KH.Lee" <redjade.lee@gmail.com> wrote in message
news:OQtKLvlZHHA.1388@TK2MSFTNGP05.phx.gbl...
> Thank for your answer ^^
>
> Sorry, but I already know that the Backtick "`" is the escape character.
>
> In the filesystem, there is no way to use the slash "/" character in the
> name of the file and directory.
>
> But, in the registry, it is possible to use the slash "/" character in
> the key name. For example,
> "HKEY_LOCAL_MACHINE\SOFTWARE\Classes\MIME\Database\Content Type" key
> contains following subkeys.
>
> --------------------------------------------------------------------
> cmd /c reg query
> "HKEY_LOCAL_MACHINE\SOFTWARE\Classes\MIME\Database\Content Type"
> --------------------------------------------------------------------
> application/atom+xml
> application/fractals
> application/futuresplash
> application/haansofthwp
> application/hta
> ...
> --------------------------------------------------------------------
> and they contains a "/" character in their's name.
>
> Simply...
>
> gci -r "HKLM:\SOFTWARE\Classes\mime\Database\Codepage"
>
> This is works fine ... But,
>
> gci -r "HKLM:\SOFTWARE\Classes\mime\Database\Content Type"
>
> this is not works,
>
> How can I list all the subkeys?
>
> Thanks.
>
>
> Brandon Shell ¾´ ±Û:
>> Backtick "`" is the escape character, but for what your doing I don't
>> see the need.
>>
>> Maybe its a language pack issue, but
>> gi "HKLM:SOFTWARE\Classes\AutoProxyTypes\Application\x-internet-signup"
>> should just work.
>>
>> --
>> Brandon Shell
>> ---------------
>> Stop by my blog some time
>> Blog: http://www.bsonposh.com/
>> PSH Scripts Project: www.codeplex.com/psobject
>> <http://www.codeplex.com/psobject>
>> --------------------------------------
>> "KH.Lee" <redjade.lee@gmail.com <mailto:redjade.lee@gmail.com>> wrote in
>> message news:Ojq5ZXhZHHA.4368@TK2MSFTNGP06.phx.gbl...
>> >I have a problem with my powershell.
>> > When I execute a command like this:
>> >
>> > gi

>> "HKLM:\SOFTWARE\Classes\AutoProxyTypes\Application/x-internet-signup"
>> >
>> > an error occurr like this:
>> >
>> > Get-Item : Cannot find path
>> >
>> >

>> 'HKEY_LOCAL_MACHINE\SOFTWARE\Classes\AutoProxyTypes\Application\x-internet-signup'
>> > because
>> > it does not exist.
>> > At line:1 char:3
>> > + gi <<<<
>> > "HKLM:\SOFTWARE\Classes\AutoProxyTypes\Application/x-internet-signup"
>> >
>> > How can I solve this problem in my powershell?


My System SpecsSystem Spec
Old 03-15-2007   #5 (permalink)
KH.Lee


 
 

Re: How can I escape a slash character in item name?

Brandon Shell ¾´ ±Û:
> I see what you mean. I think that is a bug in Get-ChildItem.
>
> This will work (did for me)
> $key = gi HKLM:\SOFTWARE\Classes\mime\Database\Content Type
> $key.GetSubKeyNames()
>
> You can also do
> $key.OpenSubKey("$subkeyName")
> like
> $key.OpenSubKey("video/x-mpeg")
>
> if you want all the subkeys you can do
> $key = gi HKLM:\SOFTWARE\Classes\mime\Database\Content Type
> foreach($sub in $key.GetSubKeyNames())
> {
> $key.OpenSubKey($sub)
> }


Thanks.
My System SpecsSystem Spec
Old 06-08-2007   #6 (permalink)
Pemo


 
 

Re: How can I escape a slash character in item name?

I also think thats a bug - you cannot use set-location within the registry
if the path contains an "illegal" character - a good (or better bad) example
is the registry entry of the n software cmdlets which is /n software
NetCmdlet (to make it appear first in line). A

cd "hklm:/Software\Microsoft\Windows\CurrentVersion\App
Management\arpcache\/n software NetCmdlet"

won't do it because of the / in the beginning.

Regads,
Peter

PS: Or may be its something only Bruce knows an answer for

"KH.Lee" <redjade.lee@gmail.com> schrieb im Newsbeitrag
news:uhsPAAvZHHA.208@TK2MSFTNGP05.phx.gbl...
> Brandon Shell ¾´ ±Û:
>> I see what you mean. I think that is a bug in Get-ChildItem.
>>
>> This will work (did for me)
>> $key = gi HKLM:\SOFTWARE\Classes\mime\Database\Content Type
>> $key.GetSubKeyNames()
>>
>> You can also do
>> $key.OpenSubKey("$subkeyName")
>> like
>> $key.OpenSubKey("video/x-mpeg")
>>
>> if you want all the subkeys you can do
>> $key = gi HKLM:\SOFTWARE\Classes\mime\Database\Content Type
>> foreach($sub in $key.GetSubKeyNames())
>> {
>> $key.OpenSubKey($sub)
>> }

>
> Thanks.



My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Re: exchange shell escape character PowerShell
Escape character question PowerShell
How do I escape the wildcard character in a path string? PowerShell
howto? escape the comment character PowerShell
Bug in escape character / variable expansion? PowerShell


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46