How to analyze REG_BINARY value in a registry key using a batch file?

Here is an example (simple):

reg add HKEY_CURRENT_USER \ Control Panel \ Desktop \ WindowMetrics / v MessageFont / t REG_BINARY / d "hex: f5, ff, ff, ff, 00.00.00.00.00.00.00.00.00.00, 00.90.01.00.00, \ 00.00.00.01.00.00.00.00.54.00.61.00.68.00.6f, 00.6d, 00.61.00 , 00.00.00.00.00, \ 00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00, 00.00.00.00.00.00, \ 00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00 "/ f

he does not work.

Thank you very much in advance.

(btw, what code tags should be used here?)

EDIT: Sorry for the delay (I didn’t get an answer here for a few days, so I searched for search queries and tried to find a solution myself), and thanks for the answer.

I solved the problem by removing the "hex" and commas. Binary values ​​should be added as a long string of numeric characters without spaces or commas.

Now I have a different problem. How can I change only the value of a record using the reg command? For example, I have to change the value of the "Default" registry entry from something to "value not set" or vice versa. If I use the "reg add" command for this, it adds another record with the same name instead of changing the existing value. I cannot use the "delete old and add new" method because it is not possible to delete the "Default" entry.

I need to do this through a batch file, not a reg file. (but in any case, it would be nice to know how this can be done using the reg file))

Many thanks

EDIT2: solution to remove the default entry value: reg delete HKLM ... \ Key / ve / f

regini should be used to change input values. http://support.microsoft.com/kb/264584 (the explanation on this page is a bit vague and perhaps even inaccurate) insert the batch file: regini c: \ testregini.txt where testregini.txt contains: HKEY_LOCAL_MACHINE ... \ Key EntryXY = somevalue (or "value not set" or something in this data type)

+6
source share
2 answers

simply:

reg add "HKCU \ Control Panel \ Desktop \ WindowMetrics" / v MessageFont / t REG_BINARY / d f5ffffff0000000000000000000000009000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 /

  • You can shorten HKEY_Current_User to HKCU.
  • Put the registry key in quotation marks to avoid parsing errors due to backslashes.
  • For the data you will need to remove the quotation marks, the prefix "hex:", commas and line breaks (backslashes) so that only numbers are left.

What is it! I am just wondering why this has not interested anyone here before.

+4
source

I'm not sure how to do this in a regular batch file, but here's how you can do it with PowerShell using an example of setting up crash actions for an ASP.NET state service:

Let's say that this is what the export of your value looks like:

[HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\services\aspnet_state] "FailureActions"=hex:50,33,01,00,00,00,00,00,00,00,00,00,03,00,00,00,0e,00,00,\ 00,01,00,00,00,00,00,00,00,01,00,00,00,00,00,00,00,01,00,00,00,00,00,00,00 

You put the hexadecimal values ​​in an array of bytes, and then use this value to set the registry value:

 $failureActionsValue = ([byte[]](80,51,01,00,00,00,00,00,00,00,00,00,03,00,00,00,14,00,00,00,01,00,00,00,00,00,00,00,01,00,00,00,00,00,00,00,01,00,00,00,00,00,00,00)) Set-ItemProperty -Path 'HKLM:\System\ControlSet001\services\aspnet_state' -Name "FailureActions" -Value $failureActionsValue 
+1
source

Source: https://habr.com/ru/post/891476/


All Articles