Convert .REG to .BAT using the command line

1

I want to set this reg key in a bat-file:

[HKEY_CLASSES_ROOT\Applications\photoviewer.dll\shell\open\command]

@=hex(2):25,00,53,00,79,00,73,00,74,00,65,00,6d,00,52,00,6f,00,6f,00,74,00,25,\ 00,5c,00,53,00,79,00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,00,72,00,75,00,\ 6e,00,64,00,6c,00,6c,00,33,00,32,00,2e,00,65,00,78,00,65,00,20,00,22,00,25,\ 00,50,00,72,00,6f,00,67,00,72,00,61,00,6d,00,46,00,69,00,6c,00,65,00,73,00,\ 25,00,5c,00,57,00,69,00,6e,00,64,00,6f,00,77,00,73,00,20,00,50,00,68,00,6f,\ 00,74,00,6f,00,20,00,56,00,69,00,65,00,77,00,65,00,72,00,5c,00,50,00,68,00,\ 6f,00,74,00,6f,00,56,00,69,00,65,00,77,00,65,00,72,00,2e,00,64,00,6c,00,6c,\ 00,22,00,2c,00,20,00,49,00,6d,00,61,00,67,00,65,00,56,00,69,00,65,00,77,00,\ 5f,00,46,00,75,00,6c,00,6c,00,73,00,63,00,72,00,65,00,65,00,6e,00,20,00,25,\ 00,31,00,00,00

I have tried do this:

reg add "HKCU\HKEY_CLASSES_ROOT\Applications\photoviewer.dll\shell\open\command" /ve /t REG_EXPAND_SZ /d %SystemRoot%\System32\rundll32.exe @=hex(2):25,00,53,00,79,00,73,00,74,00,65,00,6d,00,52,00,6f,00,6f,00,74,00,25,\
00,5c,00,53,00,79,00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,00,72,00,75,00,\
6e,00,64,00,6c,00,6c,00,33,00,32,00,2e,00,65,00,78,00,65,00,20,00,22,00,25,\
00,50,00,72,00,6f,00,67,00,72,00,61,00,6d,00,46,00,69,00,6c,00,65,00,73,00,\
25,00,5c,00,57,00,69,00,6e,00,64,00,6f,00,77,00,73,00,20,00,50,00,68,00,6f,\
00,74,00,6f,00,20,00,56,00,69,00,65,00,77,00,65,00,72,00,5c,00,50,00,68,00,\
6f,00,74,00,6f,00,56,00,69,00,65,00,77,00,65,00,72,00,2e,00,64,00,6c,00,6c,\
00,22,00,2c,00,20,00,49,00,6d,00,61,00,67,00,65,00,56,00,69,00,65,00,77,00,\
5f,00,46,00,75,00,6c,00,6c,00,73,00,63,00,72,00,65,00,65,00,6e,00,20,00,25,\
00,31,00,00,00

but this won't work. Does someone know how I can do that?

Asaph Cbp

Posted 2018-01-05T12:32:39.480

Reputation: 39

Answers

1

I would use both a .reg and .bat file.

You can simply do:

reg import myfile.reg

and it will execute that .reg file without any popup such as "the registry entries have been added"

Given the location of the registry, make sure you run the batch file as Administrator.

LPChip

Posted 2018-01-05T12:32:39.480

Reputation: 42 190

thanks but i need use just a .bat (i will convert bat to exe) – Asaph Cbp – 2018-01-05T12:40:45.693

Converting the bat to exe will still work, it just needs an .exe and .reg file then. – LPChip – 2018-01-05T12:41:24.733

Okay, I'll express myself better, I need a single file without reference to the external .reg, cause this i use command line to do... – Asaph Cbp – 2018-01-05T12:44:35.563

I don't think you have any choice here. You obviously need to put everything on one line, but given the length, commandline does not offer that much length for a single command. You could of course construct the .reg file from commandline, then import it, and then delete the .reg file again. – LPChip – 2018-01-05T12:49:03.797

Thank's, i think i have solved with this put the hex value into this {" "}, i'll test. – Asaph Cbp – 2018-01-05T12:57:22.187

1

I believe the syntax for hex data is by using the /d parameter, for example :

reg add ... /d 00010000

See reg add /? for examples.

harrymc

Posted 2018-01-05T12:32:39.480

Reputation: 306 093