Question

I am looking for a way to modify a .reg (or .txt) file that is an exported registry value. I can already export the registry file, I just need a way to change just one character that is about the middle of that hex value. Below is the part of the exported registry value and Bolded is what I am looking to change.

"F"=hex:02,00,01,00,00,00,00,00,b4,42,39,6f,86,fd,cd,01,00,00,00,00,00,00,00,\
00,d7,2f,f1,d8,0e,e9,cd,01,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
f4,01,00,00,01,02,00,00,11,02,00,00,00,00,00,00,00,00,2e,00,01,00,00,00,00,\
00,00,00,88,52,35,00

I need to change that 11 to a 10, then save that to a reg file then import it. It seems that the FOR command maybe what I need, but I have read up on the FOR command and am still confused by it.

Further Info: This will be executed in a WinPE 3.0 environment This hex value differs from PC to PC, but the 11 will always be in the same position.

Even Better: Is there something other than a batch/cmd file that I could use to modify a loaded offline registry hive to accomplish the same thing?

Thanks in advance
~Mike

Was it helpful?

Solution

First put it into a variable (I'm going to use X)

set x="F"=hex:02,00,01,00,00,00,00,00,b4,42,39,6f,86,fd,cd,01,00,00,00,00,00,00,00,\00,d7,2f,f1,d8,0e,e9,cd,01,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\f4,01,00,00,01,02,00,00,11,02,00,00,00,00,00,00,00,00,2e,00,01,00,00,00,00,\00,00,00,88,52,35,00

Then you can replace 11 with 10 by

set x=%x:11=10%

Note: Don't do this method if there would be two 11's in the script because it replace them all.

If there is more 11's but that 11 is in the same exact spot (if it was 58 characters into the line then it must be 58 characters into the line the next time) so you would count the characters leading up to the 11 and take that X variable and make another variable named 1 and the contents would look like this:

set 1=%x:~0,178%

Then find out how many characters are right after the 11 to the end and name the variable 2 and add 2 so you end up skipping the 11:

set 2=%x:~180,70%

Then after that you just input the new value in between in this case 10 so it would be:

set X=%1%10%2%

Then you have the new output back in the X variable!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top