Jump to content











Photo

[App Scripts Guide] Adding Registry keys


  • Please log in to reply
4 replies to this topic

#1 Nuno Brito

Nuno Brito

    Platinum Member

  • Team Reboot
  • 10452 posts
  • Location:boot.wim
  • Interests:I'm just a quiet simple person with a very quiet simple life living one day at a time..
  •  
    European Union

Posted 24 August 2008 - 09:58 PM

App Scripts Guide





Index

Chapter 1 - Introduction
Chapter 2 - How to create a new app script
Chapter 3 - Adding Registry keys




Chapter 3 - Adding Registry keys






Introduction



On the previous chapter we've learned how to create a single script that only required to add a few files and nothing else.

But what happens when if your program needs to read keys from the registry?

For these cases, we'll explain exactly how you can write your own registry keys on the target registry so that everything works as you need.



Explaining Registry Hives



When we are building a boot disk based on windows, it's most often the need for editing the registry structure of this boot disk and the registry keys are all collected inside binary files called registry hives.

Registry hives can commonly be found inside the Windows\System32\Config folder and as a few other special hives such as setupreg.hiv

To avoid the need of knowing the full pathnames to hives or even knowing the equivalent hives across different platforms like XP vs Vista, we use a set of alias to make your life a bit easier when it comes to know in which hive you need to write your data.

These are the values you can use when specifying a hive:
[User,Default or HKCU],[Machine or HKU] and [System or HKLM]

Note that you can select only one of the values inside brackets [].



Loading and unloading Hives




On our app script code we need to load a registry hive before writing anything new and then unload the hive when we no longer need it so that other scripts can also use the same hives.


Here is the code used for loading and unloading an hive:
Hive_Load,HKCU

Hive_Unload

Notice that the first command will tell to load the HKCU hive - this is an alias that means "Header Key for Current User" that we mentioned above.

Using this Hive_Load will tell the system to load and prepare our hive to be written. This hive will only be unloaded when we the final lines mentioning Hive_Unload are used.






Writing registry keys




After loading the respective hive comes the time when you will be able to write your registry keys.

This is done using the Reg_Add command.

Here is an example:
reg_add,0x1,"%reg%\Software\Microsoft\Windows\CurrentVersion\Explorer\Test,Temp,ABCDEFG

This code snippet will write a registry key on Software\Microsoft\Windows\CurrentVersion\Explorer\Test on valuename Temp with the ValueData of ABCDEFG

As it expected on registry keys you will also need to specify the type of key to write.

Here is a quick list of supported types:

0x1 - Plain text
0x2 - Text with expandable variables
0x3 - Binary data
0x4 - Numbers
0x7 - Multi text entries

You will need to include %reg%\ on the beginning of each registry write because this is a variable that will later be used to replace with the correct path to your loaded hive, nothing you need to worry about but very important for this command to work.





Deleting registry keys



There are cases where it might be necessary to delete keys and values from the registry.

On this situation one can use the reg_del command.

The syntax is the following:
Reg_Del,Section,Value

Using the previously mentioned example, if we now wanted to delete the newly created value we could use:
reg_del,"%reg%\Software\Microsoft\Windows\CurrentVersion\Explorer\Test,Temp


Very simple, isn't it? :whistling:




In conclusion




I hope that after reading this tutorial you're ready to start writing your own registry keys, if you're still not very confident how they are used then you can always use other app scripts as example for your own codings.

Here is an example of a few scripts using reg keys:
http://livexp.boot-l...leZilla3.script
http://livexp.boot-l...onverter.script
http://livexp.boot-l.../WackGet.script


Please post your doubts on this topic and you're also welcome to suggest what should be added or changed in the tutorial.

Thank you.

;)

#2 Reptile

Reptile

    Newbie

  • Members
  • 11 posts
  •  
    Switzerland

Posted 06 February 2013 - 11:36 AM

How can I find out which keys I have to add, If I only know the application name?

Diskcryptor for example?



#3 Wonko the Sane

Wonko the Sane

    The Finder

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

Posted 06 February 2013 - 11:40 AM

How can I find out which keys I have to add, If I only know the application name?

Diskcryptor for example?

You get them from the BartPE plugin you have:

http://reboot.pro/to...builder-script/

 

Or you trace the program, with dependency walker, procmon (or filemon and regmon) and/or similar tools.

 

:cheers:

Wonko


  • Nuno Brito likes this

#4 Reptile

Reptile

    Newbie

  • Members
  • 11 posts
  •  
    Switzerland

Posted 06 February 2013 - 01:08 PM

BTW Winbuilder gives an error reg add unkown?

Is now something different?

I saw new scripts with Reg add Key

 

Diskcryptor always wants a reboot

Of course I cant restart.


Edited by Reptile, 06 February 2013 - 01:10 PM.


#5 Wonko the Sane

Wonko the Sane

    The Finder

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

Posted 06 February 2013 - 01:29 PM

Reptile :),

the general idea of a topic is that it stays "on topic".

 

This thread is not "post here whatever issue you have with diskcryptor".

 

You already started a thread related to this.

 

Post THERE a link to the BartPE plugin you have, someone may be able to help you doing the conversion, there is a tool that usually gives good results:

http://reboot.pro/to...uilder-project/

 

Try it, then post THERE the issues you have with the generated script (if any).

 

Till now you have NOT provided any meaningful information, you won't get help unless you try and put other members in the condition to be able to help you.

 

Report what you have been trying, what EXACTLY you did, what EXACT issue you are having, etc., etc., check against this:

http://homepage.ntlw...ard-litany.html

 

 

:cheers:

Wonko






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users