![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
|
Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
br> br> |
| |||||||
![]() |
| | Thread Tools | Display Modes |
| | #1 (permalink) |
| Guest | Creating Registry-Keys with CreateSubKey-Method Hello, i have a little problem. I wish to create a Registry-Subkey and a value. I am testing if the subkey exists, if not i get with Get-Item the parent Key an use the methode CreateSubKey. But i got an error. "In diesen Registrierungsschlüssel kann nicht geschrieben werden", in englisch: "could not write in this Registry-Key". But why? manual with regedit i can create the Key. I am logged in as admin. Here ist my Code. To my mind it is correct. $strSchluessel="HKLM:\SOFTWARE" $strUSchluessel="MyTest" $strWert="Test" if ((Test-Path $strSchluessel) -eq $true) { #uebergeordneter Schluessel vorhanden if ((Test-Path ($strSchluessel + $strUSchluessel)) -eq $false) { #untergeordneter Schluessel nicht vorhanden #schluessel erstellen $Schluessel=Get-Item $strSchluessel echo $strUSchluessel $USchluessel=$Schluessel.CreateSubKey($strUSchluessel) echo "Schluessel erstellt!" } } mfg Jens. |
My System Specs![]() |
| | #2 (permalink) |
| Guest | RE: Creating Registry-Keys with CreateSubKey-Method standard the registry is opened Read-Only, you can open it to write like this : $Reg = Get-Item HKLM: $Schluessel = $reg.OpenSubKey('SOFTWARE',$true) $USchluessel=$Schluessel.CreateSubKey($strUSchluessel) $USchluessel gr /\/\o\/\/ More registry examples : http://mow001.blogspot.com/2005/10/m...ry-access.html http://mow001.blogspot.com/2005/10/startrdp-script.html "Jens Schulze" wrote: > Hello, > i have a little problem. I wish to create a Registry-Subkey and a value. I > am testing if the subkey exists, if not i get with Get-Item the parent Key > an use the methode CreateSubKey. > But i got an error. "In diesen Registrierungsschlüssel kann nicht > geschrieben werden", in englisch: "could not write in this Registry-Key". > But why? manual with regedit i can create the Key. I am logged in as admin. > > Here ist my Code. To my mind it is correct. > > $strSchluessel="HKLM:\SOFTWARE" > > $strUSchluessel="MyTest" > > $strWert="Test" > > if ((Test-Path $strSchluessel) -eq $true) > > { > > #uebergeordneter Schluessel vorhanden > > if ((Test-Path ($strSchluessel + $strUSchluessel)) -eq $false) > > { > > #untergeordneter Schluessel nicht vorhanden > > #schluessel erstellen > > $Schluessel=Get-Item $strSchluessel > > echo $strUSchluessel > > $USchluessel=$Schluessel.CreateSubKey($strUSchluessel) > > echo "Schluessel erstellt!" > > } > > } > > > mfg Jens. > > > |
My System Specs![]() |
| | #3 (permalink) |
| Guest | Re: Creating Registry-Keys with CreateSubKey-Method As an alternative approach, you could also use driveless access, which avoids both the Read-Only problem and the issue if that drive is not mapped for some reason: $strSchluessel = Get-Item Microsoft.PowerShell.Core\Registry::hklm\software "Jens Schulze" <webmaster@irgendwas.de> wrote in message news:u3lllz96GHA.4232@TK2MSFTNGP02.phx.gbl... > Hello, > i have a little problem. I wish to create a Registry-Subkey and a value. I > am testing if the subkey exists, if not i get with Get-Item the parent Key > an use the methode CreateSubKey. > But i got an error. "In diesen Registrierungsschlüssel kann nicht > geschrieben werden", in englisch: "could not write in this Registry-Key". > But why? manual with regedit i can create the Key. I am logged in as > admin. > > Here ist my Code. To my mind it is correct. > > $strSchluessel="HKLM:\SOFTWARE" > > $strUSchluessel="MyTest" > > $strWert="Test" > > if ((Test-Path $strSchluessel) -eq $true) > > { > > #uebergeordneter Schluessel vorhanden > > if ((Test-Path ($strSchluessel + $strUSchluessel)) -eq $false) > > { > > #untergeordneter Schluessel nicht vorhanden > > #schluessel erstellen > > $Schluessel=Get-Item $strSchluessel > > echo $strUSchluessel > > $USchluessel=$Schluessel.CreateSubKey($strUSchluessel) > > echo "Schluessel erstellt!" > > } > > } > > > mfg Jens. > |
My System Specs![]() |
![]() |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Mcafee Registry Keys or other | JustaUser | VB Script | 3 | 08-19-2008 05:11 PM |
| How to access the method of a registry key | Seeker | PowerShell | 1 | 08-07-2008 12:41 PM |
| Unable to delete registry keys | Art | Vista General | 3 | 12-04-2007 04:19 PM |
| BUG? Registry keys with / in names | Roman Kuzmin | PowerShell | 9 | 09-04-2007 11:58 AM |
| Vista Registry Keys | edde | Vista General | 3 | 02-19-2007 01:39 PM |