Jump to content











Photo
- - - - -

import reg files


  • Please log in to reply
22 replies to this topic

#1 billonious

billonious

    Silver Member

  • .script developer
  • 528 posts
  • Location:greezeland
  • Interests:curiosity

Posted 03 November 2008 - 04:45 PM

Regarding scripting syntax, do I have to load hives before importing an external registy file?

Running the command below as it is alone, at [process] section, gives an error, can't import the file.

RegImport,"c:\license.reg"


these commands give error too.

RegHiveLoad,"WB-Software","%TargetDir%\i386\system32\config\software"
RegHiveLoad,"WB-Setup","%TargetDir%\i386\system32\setupreg.hiv"
RegImport,%pFileBox2%
RegHiveUnLoad,"WB-Software"
RegHiveUnLoad,"WB-Setup""



#2 pscEx

pscEx

    Platinum Member

  • Team Reboot
  • 12707 posts
  • Location:Korschenbroich, Germany
  • Interests:What somebody else cannot do.
  •  
    European Union

Posted 03 November 2008 - 05:32 PM

Regarding scripting syntax, do I have to load hives before importing an external registy file?

Yes, you have to load a hive before.

But there is one thing (which should be considered to be changed):
The labels have to be consistent.

If eg. you 'RegHiveLoad,MyReg, ...'
and your .reg contains: 'RegWrite,HKLM,0x1,YourReg, ...'
it will not work as supposed.

Peter

EDIT: Just to be complete: If you want to add some reg entries into your local registry, the above is OFFTOPIC:
In this case you do not need to open a hive, and everything is written into your local registry, like it is written in the .REG file.

#3 billonious

billonious

    Silver Member

  • .script developer
  • 528 posts
  • Location:greezeland
  • Interests:curiosity

Posted 03 November 2008 - 07:16 PM

hey Peter,
I want to write in a livexp registry. I used these lines:
RegHiveLoad,"WB-Software","%TargetDir%\i386\system32\config\software"

RegHiveLoad,"WB-Setup","%TargetDir%\i386\system32\setupreg.hiv"

RegImport,"c:\license.reg"

RegHiveUnLoad,"WB-Software"

RegHiveUnLoad,"WB-Setup"

the external reg file is a simple entry

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Licenses]
"{K7C0DB872A3F777C0}"=hex:59,ff,b6,d0,0a,0e,1f,ff,ff,ff,ff,d4,e9,ae,48,54,b4,\
8a,0d,a8,75,9b,be,ab,89,bb,93,ff,ff,ff,ff,7f,66,ae,b9,c3,a3,03,3.......blah blah blah



It does load the hives succefully, but it fails to import the .reg file.
Searching the forum I found this topic.
It seems that the "regimport" command is a bit tricky.

I am to use [url="http://www.boot-land...t&p=38523"]this [/url ]Galapo's suggestion and replace totally the regimport command with the following

ShellExecute,Hide,"reg.exe","import C:\test.reg"


:EDIT:
completely failure
:cheers:
:cheers: :cheers: :cheers: :cheers:

#4 pscEx

pscEx

    Platinum Member

  • Team Reboot
  • 12707 posts
  • Location:Korschenbroich, Germany
  • Interests:What somebody else cannot do.
  •  
    European Union

Posted 03 November 2008 - 08:46 PM

hey Peter,
I want to write in a livexp registry. I used these lines:

RegHiveLoad,"WB-Software","%TargetDir%\i386\system32\config\software"

	  RegHiveLoad,"WB-Setup","%TargetDir%\i386\system32\setupreg.hiv"

	  RegImport,"c:\license.reg"

	  RegHiveUnLoad,"WB-Software"

	  RegHiveUnLoad,"WB-Setup"

the external reg file is a simple entry



It does load the hives succefully, but it fails to import the .reg file.
Searching the forum I found this topic.
It seems that the "regimport" command is a bit tricky.
Galapo's suggestion and replace totally the regimport commandwith the following



With both methods you write into the local registry, at the place where you got the entry from.

To write into the PE's registry you have to change the .reg to HKEY_LOCAL_MACHINE\WB-Software\Licenses
(Take care that the editor is unicode capable!)

Mounting setupreg.hiv is not necessary.

BTW: You can convert such reg files to WB script code by using Reg2WBs.

Peter

#5 billonious

billonious

    Silver Member

  • .script developer
  • 528 posts
  • Location:greezeland
  • Interests:curiosity

Posted 03 November 2008 - 09:29 PM

thanx peter for reply.

BTW: You can convert such reg files to WB script code by using [url="http://www.boot-land...g2wbs"]Reg2WBs.


my concept is to give to user the option to load license keys from a reg file. So, I hopefully and optimisticly keep trying to cancel any Murfy's law, and contrary to quantum mechanics predict the positive results. :cheers: :cheers:

black magic strikes my registry hives :cheers:

#6 pscEx

pscEx

    Platinum Member

  • Team Reboot
  • 12707 posts
  • Location:Korschenbroich, Germany
  • Interests:What somebody else cannot do.
  •  
    European Union

Posted 03 November 2008 - 09:40 PM

Even the highest optimism cannot bypass the fact that to write into a mounted hive, the reg key has to be changed to meet the target's name.

Peter

#7 billonious

billonious

    Silver Member

  • .script developer
  • 528 posts
  • Location:greezeland
  • Interests:curiosity

Posted 04 November 2008 - 09:56 AM

Peter, have a nice day.

Do you mean that the entry

HKEY_LOCAL_MACHINE\SOFTWARE\Licenses

have to be

HKEY_LOCAL_MACHINE\WB-Software\Licenses

?

Isn't there any automated way to do it by winbuilder at building time? :cheers::

#8 pscEx

pscEx

    Platinum Member

  • Team Reboot
  • 12707 posts
  • Location:Korschenbroich, Germany
  • Interests:What somebody else cannot do.
  •  
    European Union

Posted 04 November 2008 - 10:11 AM

Do you mean that the entry
have to be

Isn't there any automated way to do it by winbuilder at building time? :cheers: :

For this case it is correct. For other .reg input it may be very different, e.g. with CLSID.

Unfortunatelly I do not see a way for WinBuilder to automate this.
Even the TXTREPLACE is (currently) not possible, because the .reg is an unicode file.

Peter

#9 paraglider

paraglider

    Gold Member

  • .script developer
  • 1743 posts
  • Location:NC,USA
  •  
    United States

Posted 04 November 2008 - 01:09 PM

Hopefully one day winbuilder will support unicode encoded script files. Windows is natively unicode so operating with unicode strings is the best option - most of the asci apis convert to unicode internally for incoming strings and convert unicode to asci for output strings. When you want to fully support none European languages like Russian, Japanese, Chinese etc its almost essential.

#10 pscEx

pscEx

    Platinum Member

  • Team Reboot
  • 12707 posts
  • Location:Korschenbroich, Germany
  • Interests:What somebody else cannot do.
  •  
    European Union

Posted 04 November 2008 - 01:14 PM

Hopefully one day winbuilder will support unicode encoded script files.

:cheers:
I wrote '(currently)'

Peter

#11 u2o

u2o

    Frequent Member

  • .script developer
  • 257 posts
  • Location:Argentina
  •  
    Argentina

Posted 20 February 2012 - 11:23 AM

In the CommonApi are defined:

%RegSystem%=%TargetDir%windowssystem32configsystem

%RegSoftware%=%TargetDir%windowssystem32configsoftware

%RegDefault%=%TargetDir%windowssystem32configdefault

%RegUser%=%TargetDir%windowssystem32configdefault

%RegComponents%=%TargetDir%windowssystem32configCOMPONENTS

%RegSam%=%TargetDir%windowssystem32configsam

%RegSecurity%=%TargetDir%windowssystem32configsecurity


Could I import a "reg" to any of these branches?

I've seen the way on the script "Shell -> 1 - Explorer Shell", but I can't understand how.

If I would like import to the branch (Win7PE_SE offline registry) "HKEY_LOCAL_MACHINESECURITY" and...

my reg file content (security.reg)

Windows Registry Editor Version 5.00



[HKEY_LOCAL_MACHINETMP_SECURITY]



[HKEY_LOCAL_MACHINETMP_SECURITYPolicy]

@=""



[HKEY_LOCAL_MACHINETMP_SECURITYPolicyAccounts]

@=hex(0):



blah blah blah


my script content
ShellExecute,hide,%RegeditexeFolder%regedit.exe,"/s #$q%ScriptDir%security.reg#$q"

RegHiveUnLoad,TMP_SECURITY


It's valid?

---------------------

ps: reg2WBS v4.0.3.25 fails to transform .reg files with
  • value-name is "@" (in registry view it's @, but really the name is null)
  • value-type REG_QWORD

Edited by u2o, 20 February 2012 - 12:40 PM.


#12 MedEvil

MedEvil

    Platinum Member

  • .script developer
  • 7771 posts

Posted 20 February 2012 - 12:55 PM

To import a reg file, you first need to mount the hive, you want to import to, with RegHiveLoad
Then, of course, the regfile entries all have to point to that mountpoint. (You can't use an exported reg file directly!!!)
Then you can import the reg files with reg.exe or regedit.exe. (The later works better for XP.)
At the end you need to unmount the hive again with RegHiveUnload

:cheers:
  • u2o likes this

#13 u2o

u2o

    Frequent Member

  • .script developer
  • 257 posts
  • Location:Argentina
  •  
    Argentina

Posted 21 February 2012 - 06:24 AM

To import a reg file, you first need to mount the hive, you want to import to, with RegHiveLoad
Then, of course, the regfile entries all have to point to that mountpoint. (You can't use an exported reg file directly!!!)
Then you can import the reg files with reg.exe or regedit.exe. (The later works better for XP.)
At the end you need to unmount the hive again with RegHiveUnload

:cheers:


Thanks! It Works!!


If,Not,ExistVar,%RegSecurity%,Set,%RegSecurity%,%target_sys%\config\security

If,ExistFile,%ProjectTemp%\HostOSTools\regedit.exe,Set,%RegeditexeFolder%,%ProjectTemp%\HostOSTools\

If,Not,ExistFile,%ProjectTemp%\HostOSTools\regedit.exe,If,Not,%SysType%,Equal,x86,Echo,"regedit.exe MAY write wrong values",WARN



RegHiveLoad,Tmp_Security,%RegSecurity%

Message,"RegSecurity is loaded!",Information

ShellExecute,hide,%RegeditexeFolder%regedit.exe,"/s #$q%ScriptDir%\HKEY_LOCAL_MACHINE_SECURITY_RG5.reg#$q"

Message,"SECURITY RegFile is imported!",Information

RegHiveUnLoad,Tmp_Security

Message,"RegSecurity is unloaded!",Information


#14 Wonko the Sane

Wonko the Sane

    The Finder

  • Advanced user
  • 16066 posts
  • Location:The Outside of the Asylum (gate is closed)
  •  
    Italy

Posted 21 February 2012 - 08:57 AM

Wouldn't it be easier to use the Registry offline? :whistling:
http://reboot.pro/11212/
http://reboot.pro/11312/

:cheers:
Wonko

#15 MedEvil

MedEvil

    Platinum Member

  • .script developer
  • 7771 posts

Posted 21 February 2012 - 10:24 AM

How's that suppose to work?
Offlinereg is dsigned for single key operations, not to import a reg file.

:cheers:

#16 Wonko the Sane

Wonko the Sane

    The Finder

  • Advanced user
  • 16066 posts
  • Location:The Outside of the Asylum (gate is closed)
  •  
    Italy

Posted 21 February 2012 - 10:42 AM

How's that suppose to work?
Offlinereg is dsigned for single key operations, not to import a reg file.

Comeon :), you just run it more times, exactly one for each key in the reg file, just as you would use reg add on an online registry.
It is a possible answer to the more general question "How do I add settings to a Registry file?" of which the question "How do I import a reg file?" is a subset, asked with an approach similar to the x/y/z one:
http://perl.plover.c...Questions3.html

The goal IMHO is to have a given set of keys in the PE Registry, not to have them necessarily through importing a reg file.

Parrsing a reg file to feed with it's contents an offline writer would be trivial.

Still IMHO when you have something loaded/mounted and - for any reason - *something* goes wrong, you risk to have the "real" Registry cluttered with "garbage".

It's just like extracting files from WIM, set apart speed, getting them through 7-zip is inherently "safer" than mounting the WIM.

:cheers:
Wonko

#17 MedEvil

MedEvil

    Platinum Member

  • .script developer
  • 7771 posts

Posted 21 February 2012 - 11:10 AM

Can't argue with offlinereg being the safer solution.

However wehere do you see 7zip being safer, than wim mounting?

:cheers:

#18 Wonko the Sane

Wonko the Sane

    The Finder

  • Advanced user
  • 16066 posts
  • Location:The Outside of the Asylum (gate is closed)
  •  
    Italy

Posted 21 February 2012 - 11:18 AM

However wehere do you see 7zip being safer, than wim mounting?

I have seen quite a few "horror" stories on the board about mounted WIMs remained "sticky" and needing a reboot, cannot say if due to a PEBCAK or anything else, but surely something that is not loaded/mounted cannot cause problems.

:cheers:
Wonko

#19 paraglider

paraglider

    Gold Member

  • .script developer
  • 1743 posts
  • Location:NC,USA
  •  
    United States

Posted 21 February 2012 - 01:00 PM

However 7-zip does not extract the hard links correctly ( i.e. it expands them instead of creating a re-based hard link ). However so far it does not appear to create a problem.

#20 MedEvil

MedEvil

    Platinum Member

  • .script developer
  • 7771 posts

Posted 21 February 2012 - 01:00 PM

Sticky wims would count under annoying, not under dangerous or unsafe, imo.

And since wim mounting can't be avoided all zogether, i see no more danger/annoyance from mounting 3 wims over mounting just 1.

:cheers:

#21 paraglider

paraglider

    Gold Member

  • .script developer
  • 1743 posts
  • Location:NC,USA
  •  
    United States

Posted 21 February 2012 - 01:07 PM

Leaving the source boot.wim / install.wim mounted would be another way to speed up the build instead of extracting them using 7-zip.

It also would not require all that extra disk space.

#22 Wonko the Sane

Wonko the Sane

    The Finder

  • Advanced user
  • 16066 posts
  • Location:The Outside of the Asylum (gate is closed)
  •  
    Italy

Posted 21 February 2012 - 01:08 PM

However 7-zip does not extract the hard links correctly ( i.e. it expands them instead of creating a re-based hard link ). However so far it does not appear to create a problem.

Yep, but still a new app with the same "offline" approach as 7-zip has (possibly faster and with correct hard link management, etc.) wouldn't be a bad thing to have.

:cheers:
Wonko

#23 paraglider

paraglider

    Gold Member

  • .script developer
  • 1743 posts
  • Location:NC,USA
  •  
    United States

Posted 21 February 2012 - 01:11 PM

I think if you use the win 7 version of imagex and associated files on win 7 and never pollute your win 7 with the vista versions then most if not all your mounting problems will go away on win 7. Yes its slower but I have never seem a mount take longer than ~ 30 seconds.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users