Page 1 of 1 1
Topic Options
#206446 - 2012-12-12 11:53 AM Create a registry hive
Fergieman Offline
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
#206447 - 2012-12-12 12:03 PM Re: Create a registry hive [Re: Fergieman]
BradV Offline
Seasoned Scripter
****

Registered: 2006-08-16
Posts: 687
Loc: Maryland, USA
I'm not sure you can create your own hive. How would you tell windows to go out and read your hive and mount it to your location? Are you sure you don't mean that you want to create your own key?
Top
#206448 - 2012-12-12 12:10 PM Re: Create a registry hive [Re: BradV]
Fergieman Offline
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 Offline
Seasoned Scripter
****

Registered: 2006-08-16
Posts: 687
Loc: Maryland, USA
The following works:
 Code:
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 Offline
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
#206451 - 2012-12-12 12:46 PM Re: Create a registry hive [Re: Fergieman]
BradV Offline
Seasoned Scripter
****

Registered: 2006-08-16
Posts: 687
Loc: Maryland, USA
The above worked on a Windows XP system... I just went and ran it on a Windows 2008 R2 system. It worked there also. The above creates the key. Once you have that, start adding your sub-keys and values. Let's see what code you are using.
Top
#206452 - 2012-12-12 01:14 PM Re: Create a registry hive [Re: BradV]
Fergieman Offline
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 Offline
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
#206455 - 2012-12-12 02:53 PM Re: Create a registry hive [Re: Fergieman]
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4574
Loc: USA
64bit vs 32bit... I'll bet $$$ on it. ;\)

Kix is 32 bit and by default will add the registry key here (on a 64bit OS):

hkcu\software\wow6432node
or
hklm\software\wow6432node

You can force it to read the the path by add this to the top of the script...

$RC=setoption("WOW64AlternateRegView","On")

I use these all the time now:
 Code:
function HKLMSoftware32()
  $HKLMSoftware32="HKLM\Software" + iif(@onwow64,"\WOW6432Node","")
endfunction

 Code:
function HKCUSoftware32()
  $HKCUSoftware32="HKCU\Software" + iif(@onwow64,"\WOW6432Node","")
endfunction
_________________________
(... better days ahead)

Top
#206458 - 2012-12-13 10:21 AM Re: Create a registry hive [Re: Allen]
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 Offline
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
#206461 - 2012-12-13 11:54 AM Re: Create a registry hive [Re: Fergieman]
BradV Offline
Seasoned Scripter
****

Registered: 2006-08-16
Posts: 687
Loc: Maryland, USA
Take the quotes off of the REG_SZ.
Top
#206465 - 2012-12-13 04:33 PM Re: Create a registry hive [Re: BradV]
ShaneEP Moderator Offline
MM club member
*****

Registered: 2002-11-29
Posts: 2127
Loc: Tulsa, OK
The quotes around REG_SZ shouldn't matter. I use it with quotes around the type all the time.

Fergieman, I copied and pasted that line and ran it as is. It created the key fine. I'm on Win XP home SP3.

Top
#206477 - 2012-12-13 07:30 PM Re: Create a registry hive [Re: ShaneEP]
BradV Offline
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
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 2312 anonymous users online.
Newest Members
fgarcia, Viginette, ManuvdWielNL, Sir_Barrington, batdk82
17889 Registered Users

Generated in 0.17 seconds in which 0.12 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org