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?
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.