@echo off & setlocal enableextensions
::
set HexString=48 65 6C 6C 6F 20 77 6F 72 6C 64 21
::
:: Build a Visual Basic Script
set vbs_=%temp%\hexdec.vbs
set skip=
findstr "'%skip%VBS" "%~f0" > "%vbs_%"
:: Run it with Microsoft Windows Script Host Version 5.6
for /f "tokens=* delims=" %%a in (
'cscript //nologo "%vbs_%" "%HexString%"') do set AsciiString=%%a
::
:: Clean up
for %%f in ("%vbs_%") do if exist %%f del %%f
::
:: Show the result
echo %HexString%
echo %AsciiString%
endlocal & goto :EOF
'
'................................................................
'The Visual Basic Script
set arg = WScript.Arguments 'VBS
WScript.Echo HexStringToAsciiString(arg(0)) 'VBS
'
Function HexStringToAsciiString(HexStr) 'VBS
For i = 1 To Int(Len(HexStr)/3)+1 'VBS
str1 = str1 & Chr("&H" & Mid(HexStr,3*i-2,2)) 'VBS
Next 'VBS
HexStringToAsciiString=str1 'VBS
End Function 'VBS
The output will be
D:\TEST>cmdfaq
48 65 6C 6C 6F 20 77 6F 72 6C 64 21
Hello world!