I have scripted Str2Hex.bat to return the hexadecimal representation of a string.

The syntax for using Str2Hex.bat is:

call Str2Hex String HexString

Where:

String    is the string you wish to represent in hexadecimal.

HexString is a call directed environment variable that will contain hexadecimal representation of String.

Example

call str2hex "Hello World" hw

Typing @echo %hw% displays 48656C6C6F20576F726C64

Str2Hex.bat contains:

@echo off
if \{%2\}==\{\} @echo Syntax: Str2Hex String HexString&goto :EOF
if exist "%TEMP%\Str2Hex.vbs" goto cvt
@echo.dim  objArguments>"%TEMP%\Str2Hex.vbs"
@echo.set objArguments = Wscript.Arguments>>"%TEMP%\Str2Hex.vbs"
@echo.str=objArguments(0)>>"%TEMP%\Str2Hex.vbs"
@echo.For i = 1 To Len(str)>>"%TEMP%\Str2Hex.vbs"
@echo. hx=hx ^&  Right("0" ^& hex(CStr(Asc(Mid(str, i, 1)))), 2)>>"%TEMP%\Str2Hex.vbs"
@echo.Next>>"%TEMP%\Str2Hex.vbs"
@echo.Wscript.Echo hx>>"%TEMP%\Str2Hex.vbs"
:cvt
for /f "Tokens=*" %%x in ('cscript //nologo "%TEMP%\Str2Hex.vbs" %1') do (
 set %2=%%x
)