Hallo,
Howto convert multiline_hex to string?
(which read from registry before)
Example:
-Source:
DhcpDefaultGateway"=hex(7):31,00,39,00,32,00,2e,00,31,00,36,00,38,00,2e,00,37,\
00,33,00,2e,00,33,00,33,00,00,00,00,00
-Result (expected):
IP=192.168.73.33
link to thread are welcome.
regards Hans
convert reg:multiline_hex to string
Moderator: DosItHelp
Re: convert reg:multiline_hex to string
If you search the forums you will probably find your answer on converting hex to ascii. It has been discussed at great length. But for numbers you don't even need a brain. It is always the second number of the hex code.
Re: convert reg:multiline_hex to string
Hans
that code might work for you:
Regards
aGerman
that code might work for you:
Code: Select all
@echo off &setlocal
set "infile=test.reg"
setlocal EnableDelayedExpansion
set "continue="
for /f %%i in ('type "!infile!"') do (
set "ln=%%i"
if !ln:~0^,20!=="DhcpDefaultGateway" (
set "hex=!ln:*:=!"
) else if defined continue (
set "hex=!hex!!ln!"
)
if "!hex:~-1!"=="\" (
set "hex=!hex:~,-1!"
set "continue=1"
) else set "continue="
)
set "gateway="
for %%i in (!hex!) do (
if "%%i" neq "00" (
set /a n=0x%%i
cmd /c exit !n!
set "gateway=!gateway!!=ExitCodeAscii!"
)
)
endlocal &set "gateway=%gateway%"
echo %gateway%
pause
Regards
aGerman