How to write registry information to WinPE

  

When adding an external program to PE, sometimes you need to write registry information for the added program. How can this be done? Here is an introduction.

Use Regsnap to trace and analyze the contents of the software to be added to the registry in a standard Windows environment, then export the registry modification entries and rewrite them into batch files and save them in the directory where the software is located. .

For example, the registration information of the ACDSEE programs is tracked and saved:

X:PROGRAMS graphic image ACDSEEACDSEE.CMD

It is recommended to refer to X:PROGRAMS graphic image ACDSEE The way the program is saved saves the software you want to add. The principle is to store it in the same directory as the main program (including the icon files that may be used), so that you can maintain the changes later. Create a registration batch file of your own application with reference to the format and style of the ACDSEE.CMD registration batch.

Note: In order to ensure that these scripts can be run in both the PE environment and the standard Windows environment, we need to detect the actual path or drive letter of the program.

When creating a batch, the first two lines are used to detect the current directory location, and the variables to be retained and referenced:

SET Var0=%0

FOR /f "delims=" %%I in ("%Var0%") do Set OP=%%~dpI

The above two lines are used to detect the path of the current batch. Obtain the drive letter of the partition in which it is located, so use %OP% in the subsequent batch as the partition number to be used in the plugin path. %OP% is only relevant to the drive letter, regardless of the path, so you need to add a detailed path to the drive letter variable %OP% in your batch. For example:

REG ADD HKCRACDC_JIFShellACDSEEenCommand /ve /t REG_SZ /d ""%OP%ACDSEE.EXE" /v" /f>NUL

The above commands can be added to the registry A registration message.

Note: When Set OP=%%~dpI in the above path detection command, it is not necessary to add “” after the variable %OP%. As %OP%ACDSEE.EXE above.

You can also use Set OP=%%~dI. Compared with the above, just change ~dpI to ~dI. At this time, the variable will not expand to the current path, but only expand to the current Drive letter. So if you use this, you must add the full path to the program after the variable. For example:

%OP%PROGRAMSTOTALCMDRUNTC.EXE

Copyright © Windows knowledge All Rights Reserved