Hex String to Reg File/Import Fail -


explanation


okay, gist of i'm trying accomplish. wrote batch file named str2hex2reg.bat (refer below batch script) called during installation of program, this:

str2hex2reg.bat c:\users\%username%\appdata\local\temp\libfile.dll

this batch file take filepath string , convert hex , save it's output registry file following:

windows registry editor version 5.00   [hkey_local_machine\software\company\program\component\settings]  "fullpath"=hex:43,3a,5c,55,73,65,72,73,5c,44,65,76,69,6e,5c,41,70,70,44,61,74,61,5c,4c,6f,63,61,6c,5c,54,65,6d,70,5c,6c,69,62,46,69,6c,65,2e,64,6c,6c  

i quite pleased wrote batch file function , work correctly until point.

problem


okay here's run problem. key fullpath has string converted hex output , when open reg file looks correct; however, know fullpath key needs value this:

[hkey_local_machine\software\company\program\component\settings]  "fullpath"=hex:43,3a,5c,55,73,65,72,73,5c,44,65,76,69,6e,5c,41,\ 70,70,44,61,74,61,5c,4c,6f,63,61,6c,5c,54,65,6d,70,5c,6c,69,62,\ 46,69,6c,65,2e,64,6c,6c  

i've tried countless times trying insert "\" after many characters no avail. i've tried following command:

reg add "%tree%" /v fullpath /t reg_binary /d %hex% 

which added before bottom half of batch script takes final converted hex string , adds "," every 2 characters. reluctantly, trying use reg add value registry directly whatever reason not working either.

question


so i've broken down after countless hours of frustration; ask fellow stack overflowians (lol) there i'm not doing correctly? there i'm leaving out or missing? there better way string hex reg file can import reg file after function in installer completes?

the batch script

str2hex2reg.bat

@echo off setlocal enabledelayedexpansion  :stringtohex set /p "=%~1" < nul > chr.tmp  %%a in (chr.tmp) fsutil file createnew zero.tmp %%~za > nul  set "hex=" /f "skip=1 tokens=2" %%a in ('fc /b chr.tmp zero.tmp') set "hex=!hex!%%a"  del chr.tmp zero.tmp  set text=%hex% set output=  /l %%i in (0,2,500) (     call set letter=!text:~%%i,2!     if not "!letter!" == "" (         set output=!output!,!letter!     ) else (         goto finished     ) )  :finished set output=%output:~1,999% set ver=windows registry editor version 5.00 set tree=[hkey_local_machine\software\company\program\component\settings] set key1="fullpath"=hex:%output%  @echo %ver% > import.reg @echo. >> import.reg @echo %tree% >> import.reg @echo %key1% >> import.reg  endlocal 

str2hex2reg.bat c:\users\devin\appdata\local\temp\libfile.dll 

with changed last lines:

 >"import.reg" echo %ver%  >>"import.reg" echo. >>"import.reg" echo %tree% :loop if "%key1:~63%" neq "" ( >>"import.reg" echo %key1:~0,63%\ set "key1=!key1:~63!" goto :loop ) >>"import.reg" echo %key1% 

will output:

> type import.reg windows registry editor version 5.00  [hkey_local_machine\software\company\program\component\settings] "fullpath"=hex:43,3a,5c,55,73,65,72,73,5c,44,65,76,69,6e,5c,41,\ 70,70,44,61,74,61,5c,4c,6f,63,61,6c,5c,54,65,6d,70,5c,6c,69,62,\ 46,69,6c,65,2e,64,6c,6c 

Comments

Popular posts from this blog

ios - MKAnnotationView layer is not of expected type: MKLayer -

ZeroMQ on Windows, with Qt Creator -

unity3d - Unity SceneManager.LoadScene quits application -