#22388
Patrick C
Participant

Dear LifeTimer,

Sorry I wasn’t able to post this earlier, though better late than never…

How to pass command line arguments using registry values without having to close EmEditor:

Approach 1: using multiple command line statements

reg add "HKCU\_Patrick_custom_" /v str1 /t REG_SZ    /f /d "ab cd"
reg add "HKCU\_Patrick_custom_" /v str2 /t REG_SZ    /f /d "1234"
reg add "HKCU\_Patrick_custom_" /v num1 /t REG_DWORD /f /d 1234

Regarding the syntax:
// /v value name (“variable name”)
// /t variable type: REG_SZ = string; REG_DWORD = 32-bit integer
// /f force overwrite already existing value without prompting for Y/N
// /d data to be written (“assigned to the variable”)

to visualise the values in the registry:
Registry

then call the EmEditor macro
"c:\Program Files\EmEditor\EmEditor.exe" /mf "d:\tmp\mymacro.jsee

with the macro code being

var WshShell = new ActiveXObject( "WScript.Shell" );
var str1 = WshShell.RegRead( "HKCU\\_Patrick_custom_\\str1" );
var str2 = WshShell.RegRead( "HKCU\\_Patrick_custom_\\str2" );
var num1 = WshShell.RegRead( "HKCU\\_Patrick_custom_\\num1" );
alert( str1 );
alert( str2 + 1 );   // an imported string is not automatically a number
alert( num1 + 1);    // an imported DWORD really is an integer

Approach 2: using one single command line statement
If, and only if it really has to be a one liner:
reg add "HKCU\_Patrick_custom_" /v str1 /t REG_SZ /f /d "xyz" && "c:\Program Files\EmEditor\EmEditor.exe" /mf "d:\tmp\mymacro.jsee"

I hope this will be of use for someone.

Credits:
https://www.windowscentral.com/how-edit-registry-using-command-prompt-windows-10
http://www.emeditor.org/en/macro_tutorial_tutorial_regread.html