#206446 - 2012-12-12 11:53 AM
Create a registry hive
|
Fergieman
Getting the hang of it
Registered: 2010-02-25
Posts: 58
Loc: Ireland
|
Guys
I am trying to create a new registry key , but not any values within it. I do use WriteValue when I want to create a key within a hive,
I want to get a key in HKCU\Software\NEWKEY and HKLM\Software\NEWKEY but the writevalue doesn't create it. Cheers guys
Edited by Fergieman (2012-12-12 12:14 PM)
|
|
Top
|
|
|
|
#206448 - 2012-12-12 12:10 PM
Re: Create a registry hive
[Re: BradV]
|
Fergieman
Getting the hang of it
Registered: 2010-02-25
Posts: 58
Loc: Ireland
|
Yes , that's what Im talking about .
I want to create my own key under those hives. Apols for the confusion
|
|
Top
|
|
|
|
#206449 - 2012-12-12 12:25 PM
Re: Create a registry hive
[Re: Fergieman]
|
BradV
Seasoned Scripter
  
Registered: 2006-08-16
Posts: 687
Loc: Maryland, USA
|
The following works: DIM $strKeyB, $strLoc, $strRet
$strKeyB = "HKCU\Software\Newkey"
$strLoc = ""
$strRet = WriteValue($strKeyB, $strLoc, 0, REG_DWORD)
If @ERROR = 0
"Created the new key" ?
Else
"There was an error writing to the registry, " + $strKeyB + "\" + $strLoc ?
EndIf
Where are you having a problem?
|
|
Top
|
|
|
|
#206450 - 2012-12-12 12:33 PM
Re: Create a registry hive
[Re: BradV]
|
Fergieman
Getting the hang of it
Registered: 2010-02-25
Posts: 58
Loc: Ireland
|
Thanks BradV.
That does not work for me. I have tried something similar but it refuses to create the new key. The values get created fine once the keys and parents key exist.
|
|
Top
|
|
|
|
#206452 - 2012-12-12 01:14 PM
Re: Create a registry hive
[Re: BradV]
|
Fergieman
Getting the hang of it
Registered: 2010-02-25
Posts: 58
Loc: Ireland
|
Hi Brad
I am using your script exactly. The message says the key was created but when I check the registry it is not there. I am using a Windows 7 box
Edited by Fergieman (2012-12-12 01:17 PM)
|
|
Top
|
|
|
|
#206453 - 2012-12-12 01:21 PM
Re: Create a registry hive
[Re: Fergieman]
|
Fergieman
Getting the hang of it
Registered: 2010-02-25
Posts: 58
Loc: Ireland
|
wait....i'll try it on another box just in cause mine is feiced
|
|
Top
|
|
|
|
#206458 - 2012-12-13 10:21 AM
Re: Create a registry hive
[Re: Allen]
|
Anonymous
Anonymous
Unregistered
|
Hi Allen - its a 32bit o/s
|
|
Top
|
|
|
|
#206460 - 2012-12-13 11:13 AM
Re: Create a registry hive
[Re: Anonymous]
|
Fergieman
Getting the hang of it
Registered: 2010-02-25
Posts: 58
Loc: Ireland
|
Ok , ive test this on a number of different pcs and it is not creating the regkey anyway in any hive (hkcu/hklm)
This was working , so can somebody try the following and see if it enters into your machines registry
WriteValue("HKEY_LOCAL_MACHINE\SOFTWARE\NewPrint\Factory4", "RegName", "GPE", "REG_SZ")
|
|
Top
|
|
|
|
#206477 - 2012-12-13 07:30 PM
Re: Create a registry hive
[Re: ShaneEP]
|
BradV
Seasoned Scripter
  
Registered: 2006-08-16
Posts: 687
Loc: Maryland, USA
|
It was just a guess since none of my scripts have quotes around the value type. 
I just used the script I posted above, changed from a default dword value to the given value and added another depth layer to the example I provided in the script. It created it just fine. If that isn't working for you, you may have other problems.
|
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
0 registered
and 2312 anonymous users online.
|
|
|