Page 1 of 1

Exporting two keys from Registry residing in two different places on Windows 10

Posted: 06 Jan 2023 07:06
by DOSadnie
My understanding of

Code: Select all

reg export /?
tells me that it is impossible to export two sub-keys from two different sub-keys [i.e. from two different places]. And also empirically by the means of creating BAT file with

Code: Select all

reg export "HKEY_CURRENT_USER\Console" "HKEY_USERS\S-1-5-21-3797103458-798797042-3558267449-1001\Console" "C:\Users\YOUR-USER-NAME\Documents\CMD _ PowerShell Settings.reg"

Code: Select all

reg export "HKEY_CURRENT_USER\Console HKEY_USERS\S-1-5-21-3797103458-798797042-3558267449-1001\Console" "C:\Users\YOUR-USER-NAME\Documents\CMD _ PowerShell Settings.reg"

Code: Select all

reg export "HKEY_CURRENT_USER\Console" reg export "HKEY_USERS\S-1-5-21-3797103458-798797042-3558267449-1001\Console" "C:\Users\YOUR-USER-NAME\Documents\CMD _ PowerShell Settings.reg"
codes failed in yielding me a result of creating for me any REG. And my goal is to export both Registry keys [i.e. HKEY_CURRENT_USER\Console and HKEY_USERS\S-1-5-21-3797103458-798797042-3558267449-1001\Console] at the same time and to one file

And so: how can I do that; either with batch scripting or some other workaround?

Re: Exporting two keys from Registry residing in two different places on Windows 10

Posted: 07 Jan 2023 05:49
by Lucky4Me
This should do the trick!

Code: Select all

reg export "HKEY_CURRENT_USER\Console" "%userprofile%\Documents\1.reg"
reg export "HKEY_USERS\S-1-5-21-3797103458-798797042-3558267449-1001\Console" "%userprofile%\Documents\2.reg"
echo Windows Registry Editor Version 5.00>"%userprofile%\Documents\CMD _ PowerShell Settings.reg"
type "%userprofile%\Documents\1.reg" | find /v "Windows Registry Editor Version 5.00">>"%userprofile%\Documents\CMD _ PowerShell Settings.reg"
type "%userprofile%\Documents\2.reg" | find /v "Windows Registry Editor Version 5.00">>"%userprofile%\Documents\CMD _ PowerShell Settings.reg"
del "%userprofile%\Documents\1.reg"
del "%userprofile%\Documents\2.reg"
copy the code and put it in a file regextract.bat, save it and run it

Re: Exporting two keys from Registry residing in two different places on Windows 10

Posted: 08 Jan 2023 10:16
by miskox
Some changes to Lucky's solution:

Code: Select all

@echo off
reg export "HKEY_CURRENT_USER\Console" "%userprofile%\Documents\CMD _ PowerShell Settings.reg"
reg export "HKEY_USERS\S-1-5-21-3797103458-798797042-3558267449-1001\Console" "%userprofile%\Documents\1.reg"
type "%userprofile%\Documents\1.reg" | find /v "Windows Registry Editor Version 5.00">>"%userprofile%\Documents\CMD _ PowerShell Settings.reg"
del "%userprofile%\Documents\1.reg"
Saso

Re: Exporting two keys from Registry residing in two different places on Windows 10

Posted: 13 Jan 2023 07:21
by DOSadnie
Solution by @Lucky works A-OK, while the one by @miskox worsks half way: it writes in the latter part of REG file
਍䡛䕋彙单剅屓ⵓⴱⴵㄲ㌭㤷ㄷ㌰㔴ⴸ㤷㜸㜹㐰ⴲ㔳㠵㘲㐷㤴ㄭ〰就潃獮汯嵥਍䌢汯牯慔汢づ∰搽潷摲〺〰っっൣ∊潃潬呲扡敬㄰㴢睤牯㩤〰慤㜳〰਍䌢汯牯慔汢づ∲搽潷摲〺〰慥ㄱള∊潃潬呲扡敬㌰㴢睤牯㩤〰摤㘹愳਍䌢汯牯慔汢づ∴搽潷摲〺㄰て捦വ∊潃潬呲扡敬㔰㴢睤牯㩤〰㠹㜱㠸਍䌢汯牯慔汢づ∶搽潷摲〺〰㤰捣റ∊潃潬呲扡敬㜰㴢睤牯㩤〰捣捣捣਍䌢汯牯慔汢づ∸搽潷摲〺㜰㜶㜶ശ∊潃潬呲扡敬㤰㴢睤牯㩤〰晦㠷戳਍䌢汯牯慔汢ㅥ∰搽潷摲〺〰捣ㄶശ∊潃潬呲扡敬ㄱ㴢睤牯㩤〰㙤㙤ㄶ਍䌢汯牯慔汢ㅥ∲搽潷摲〺㔰㐶攸ഷ∊潃潬呲扡敬㌱㴢睤牯㩤〰改〰㑢਍䌢汯牯慔汢ㅥ∴搽潷摲〺愰昵昱ഹ∊潃潬呲扡敬㔱㴢睤牯㩤〰㉦㉦㉦਍䌢牴䭬祥桓牯捴瑵䑳獩扡敬≤搽潷摲〺〰〰〰ര∊畃獲牯潃潬≲搽潷摲昺晦晦晦൦∊畃獲牯楓敺㴢睤牯㩤〰〰〰㤱਍䐢晥畡瑬慂正牧畯摮㴢睤牯㩤晦晦晦晦਍䐢晥畡瑬潆敲牧畯摮㴢睤牯㩤晦晦晦晦਍䔢慮汢䍥汯牯敓敬瑣潩≮搽潷摲〺〰〰〰ര∊硅整摮摥摅瑩敋≹搽潷摲〺〰〰〰റ∊硅整摮摥摅瑩敋䍹獵潴≭搽潷摲〺〰〰〰ര∊慆散慎敭㴢弢䑟晥畡瑬呔潆瑮彟ഢ∊楆瑬牥湏慐瑳≥搽潷摲〺〰〰〰റ∊潆瑮慆業祬㴢睤牯㩤〰〰〰〰਍䘢湯却穩≥搽潷摲〺㄰〰〰ര∊潆瑮敗杩瑨㴢睤牯㩤〰〰〰〰਍䘢牯散㉖㴢睤牯㩤〰〰〰㄰਍䘢汵卬牣敥≮搽潷摲〺〰〰〰ര∊楈瑳牯䉹晵敦卲穩≥搽潷摲〺〰〰㌰ല∊楈瑳牯乹䑯灵㴢睤牯㩤〰〰〰〰਍䤢獮牥䵴摯≥搽潷摲〺〰〰〰റ∊楌敮敓敬瑣潩≮搽潷摲〺〰〰〰റ∊楌敮牗灡㴢睤牯㩤〰〰〰㄰਍䰢慯䍤湯浉≥搽潷摲〺〰〰〰റ∊畎扭牥晏楈瑳牯䉹晵敦獲㴢睤牯㩤〰〰〰㐰਍倢灯灵潃潬獲㴢睤牯㩤〰〰〰㕦਍儢極正摅瑩㴢睤牯㩤〰〰〰㄰਍匢牣敥䉮晵敦卲穩≥搽潷摲㈺㈳〹㜰സ∊捓敲湥潃潬獲㴢睤牯㩤〰〰〰㜰਍匢牣汯卬慣敬㴢睤牯㩤〰〰〰㄰਍吢牥業慮卬牣汯楬杮㴢睤牯㩤〰〰〰〰਍吢楲䱭慥楤杮敚潲≳搽潷摲〺〰〰〰ര∊楗摮睯汁桰≡搽潷摲〺〰〰昰൦∊楗摮睯楓敺㴢睤牯㩤〰攱〰㠷਍圢牯䑤汥浩瑩牥≳搽潷摲〺〰〰〰ര∊畃牲湥側条≥搽潷摲〺〰〰〰ളഊ嬊䭈奅啟䕓卒卜ㄭ㔭㈭ⴱ㜳㜹〱㐳㠵㜭㠹㤷〷㈴㌭㔵㈸㜶㐴ⴹ〱㄰䍜湯潳敬╜祓瑳浥潒瑯弥祳瑳浥㈳损摭攮數൝∊潃潬呲扡敬〰㴢睤牯㩤〰昱ㄲ㌲਍䌢汯牯慔汢づ∵搽潷摲〺〰搰晥൦∊潃潬呲扡敬㜰㴢睤牯㩤〰〰敤〰਍䌢汯牯慔汢ㅥ∵搽潷摲〺㄰晦昲ല∊潆瑮楓敺㴢睤牯㩤〰ㄱ〰戰਍䘢湯䙴浡汩≹搽潷摲〺〰〰㌰ശ∊潆瑮敗杩瑨㴢睤牯㩤〰〰㄰〹਍䘢捡乥浡≥∽界楣慤䌠湯潳敬ഢ∊畃獲牯祔数㴢睤牯㩤〰〰〰〰਍䤢瑮牥散瑰潃祰慐瑳≥搽潷摲〺〰〰〰ര∊畃獲牯潃潬≲搽潷摲〺〰〰搰൥∊捓敲湥潃潬獲㴢睤牯㩤〰〰〰㜴਍䌢汯牯慔汢づ∴搽潷摲〺㄰ㅢ㉥റഊ嬊䭈奅啟䕓卒卜ㄭ㔭㈭ⴱ㜳㜹〱㐳㠵㜭㠹㤷〷㈴㌭㔵㈸㜶㐴ⴹ〱㄰䍜湯潳敬╜祓瑳浥潒瑯弥祓瑳浥㈳坟湩潤獷潐敷卲敨汬癟⸱弰潰敷獲敨汬攮數൝∊潃潬呲扡敬㔰㴢睤牯㩤〰㘵㐲㄰਍䌢汯牯慔汢づ∶搽潷摲〺昰攰敤൥∊慆散慎敭㴢䰢捵摩⁡潃獮汯≥਍䘢湯䙴浡汩≹搽潷摲〺〰〰㌰ശ∊潆瑮敗杩瑨㴢睤牯㩤〰〰㄰〹਍倢灯灵潃潬獲㴢睤牯㩤〰〰〰㍦਍匢牣敥䉮晵敦卲穩≥搽潷摲〺扢〸㜰സ∊捓敲湥潃潬獲㴢睤牯㩤〰〰〰㘵਍圢湩潤卷穩≥搽潷摲〺㌰〲㜰സ∊潆瑮楓敺㴢睤牯㩤〰ㄱ〰〰਍䌢牵潳呲灹≥搽潷摲〺〰〰〰ര∊湉整捲灥䍴灯偹獡整㴢睤牯㩤〰〰〰〰਍䌢牵潳䍲汯牯㴢睤牯㩤〰〰〰敤਍਍䡛䕋彙单剅屓ⵓⴱⴵㄲ㌭㤷ㄷ㌰㔴ⴸ㤷㜸㜹㐰ⴲ㔳㠵㘲㐷㤴ㄭ〰就潃獮汯履匥獹整剭潯╴卟獹佗㙗弴浣⹤硥嵥਍䌢汯牯慔汢づ∰搽潷摲〺㄰ㅢ㉥റ∊潃潬呲扡敬㔰㴢睤牯㩤〰〰㡣慦਍䌢汯牯慔汢づ∷搽潷摲〺〰挰昸ൡ∊潃潬呲扡敬㔱㴢睤牯㩤〰昱ㄲ㌲਍匢牣敥䉮晵敦卲穩≥搽潷摲㈺㈳〹攰ൢ∊楗摮睯楓敺㴢睤牯㩤〰戳〰扥਍䘢湯却穩≥搽潷摲〺㄰〱〰ൢ∊潆瑮慆業祬㴢睤牯㩤〰〰〰㘳਍䘢湯坴楥桧≴搽潷摲〺〰〰㤱ര∊慆散慎敭㴢䰢捵摩⁡潃獮汯≥਍䌢牵潳呲灹≥搽潷摲〺〰〰〰ര∊湉整捲灥䍴灯偹獡整㴢睤牯㩤〰〰〰〰਍䌢牵潳䍲汯牯㴢睤牯㩤〰〰〰㉦਍਍䡛䕋彙单剅屓ⵓⴱⴵㄲ㌭㤷ㄷ㌰㔴ⴸ㤷㜸㜹㐰ⴲ㔳㠵㘲㐷㤴ㄭ〰就潃獮汯履匥獹整剭潯╴卟獹佗㙗弴楗摮睯偳睯牥桓汥彬ㅶ〮灟睯牥桳汥⹬硥嵥਍䌢汯牯慔汢づ∵搽潷摲〺㔰㈶〴റ∊潃潬呲扡敬㘰㴢睤牯㩤〰て摥敥਍䘢捡乥浡≥∽界楣慤䌠湯潳敬ഢ∊潆瑮慆業祬㴢睤牯㩤〰〰〰㘳਍䘢湯坴楥桧≴搽潷摲〺〰〰㤱ര∊潐異䍰汯牯≳搽潷摲〺〰〰昰ള∊捓敲湥畂晦牥楓敺㴢睤牯㩤戰㡢〰慥਍匢牣敥䍮汯牯≳搽潷摲〺〰〰㔰ശ∊楗摮睯楓敺㴢睤牯㩤〰戳〰慥਍䘢湯却穩≥搽潷摲〺㄰〱〰ര∊畃獲牯祔数㴢睤牯㩤〰〰〰〰਍䤢瑮牥散瑰潃祰慐瑳≥搽潷摲〺〰〰〰ര∊畃獲牯潃潬≲搽潷摲〺〰〰搰൥ഊ
instead of content of

HKEY_USERS\S-1-5-21-3797103458-798797042-3558267449-1001\Console

address; which is stunning to me because I do not use an Asian language. I mean: what is that and where does it come from?

Re: Exporting two keys from Registry residing in two different places on Windows 10

Posted: 18 Jan 2023 08:15
by penpen
What you see there is a character encoding issue.
Somehow the resulting file was created with the byte order mark (bom) of 'UTF-16 LE' (which could happen for various reasons).
Then the reg file was appended.

Save the text into a file using encoding 'UTF-16 LE'.
Then open it within a hex-editor.
Delete the first two bytes (which in hex are: FF FE),save the result and open as an ANSI file.
Then you see, that the text says:

Code: Select all

[HKEY_USERS\S-1-5-21-3797103458-798797042-3558267449-1001\Console]
"ColorTable00"=dword:000c0c0c
"ColorTable01"=dword:00da3700
"ColorTable02"=dword:000ea113
"ColorTable03"=dword:00dd963a
"ColorTable04"=dword:001f0fc5
"ColorTable05"=dword:00981788
"ColorTable06"=dword:00009cc1
"ColorTable07"=dword:00cccccc
"ColorTable08"=dword:00767676
"ColorTable09"=dword:00ff783b
"ColorTable10"=dword:000cc616
"ColorTable11"=dword:00d6d661
"ColorTable12"=dword:005648e7
"ColorTable13"=dword:009e00b4
"ColorTable14"=dword:00a5f1f9
"ColorTable15"=dword:00f2f2f2
"CtrlKeyShortcutsDisabled"=dword:00000000
"CursorColor"=dword:ffffffff
"CursorSize"=dword:00000019
"DefaultBackground"=dword:ffffffff
"DefaultForeground"=dword:ffffffff
"EnableColorSelection"=dword:00000000
"ExtendedEditKey"=dword:00000001
"ExtendedEditKeyCustom"=dword:00000000
"FaceName"="__DefaultTTFont__"
"FilterOnPaste"=dword:00000001
"FontFamily"=dword:00000000
"FontSize"=dword:00100000
"FontWeight"=dword:00000000
"ForceV2"=dword:00000001
"FullScreen"=dword:00000000
"HistoryBufferSize"=dword:00000032
"HistoryNoDup"=dword:00000000
"InsertMode"=dword:00000001
"LineSelection"=dword:00000001
"LineWrap"=dword:00000001
"LoadConIme"=dword:00000001
"NumberOfHistoryBuffers"=dword:00000004
"PopupColors"=dword:000000f5
"QuickEdit"=dword:00000001
"ScreenBufferSize"=dword:23290078
"ScreenColors"=dword:00000007
"ScrollScale"=dword:00000001
"TerminalScrolling"=dword:00000000
"TrimLeadingZeros"=dword:00000000
"WindowAlpha"=dword:000000ff
"WindowSize"=dword:001e0078
"WordDelimiters"=dword:00000000
"CurrentPage"=dword:00000003

[HKEY_USERS\S-1-5-21-3797103458-798797042-3558267449-1001\Console\%SystemRoot%_system32_cmd.exe]
"ColorTable00"=dword:001f2123
"ColorTable05"=dword:0000deff
"ColorTable07"=dword:0000de00
"ColorTable15"=dword:001ff2f2
"FontSize"=dword:0011000b
"FontFamily"=dword:00000036
"FontWeight"=dword:00000190
"FaceName"="Lucida Console"
"CursorType"=dword:00000000
"InterceptCopyPaste"=dword:00000000
"CursorColor"=dword:000000de
"ScreenColors"=dword:00000047
"ColorTable04"=dword:001b1e21

[HKEY_USERS\S-1-5-21-3797103458-798797042-3558267449-1001\Console\%SystemRoot%_System32_WindowsPowerShell_v1.0_powershell.exe]
"ColorTable05"=dword:00562401
"ColorTable06"=dword:00f0edee
"FaceName"="Lucida Console"
"FontFamily"=dword:00000036
"FontWeight"=dword:00000190
"PopupColors"=dword:000000f3
"ScreenBufferSize"=dword:0bb80078
"ScreenColors"=dword:00000056
"WindowSize"=dword:00320078
"FontSize"=dword:00110000
"CursorType"=dword:00000000
"InterceptCopyPaste"=dword:00000000
"CursorColor"=dword:000000de

[HKEY_USERS\S-1-5-21-3797103458-798797042-3558267449-1001\Console\%SystemRoot%_SysWOW64_cmd.exe]
"ColorTable00"=dword:001b1e21
"ColorTable05"=dword:0000c8fa
"ColorTable07"=dword:0000c8fa
"ColorTable15"=dword:001f2123
"ScreenBufferSize"=dword:232900eb
"WindowSize"=dword:003b00eb
"FontSize"=dword:0011000b
"FontFamily"=dword:00000036
"FontWeight"=dword:00000190
"FaceName"="Lucida Console"
"CursorType"=dword:00000000
"InterceptCopyPaste"=dword:00000000
"CursorColor"=dword:000000f2

[HKEY_USERS\S-1-5-21-3797103458-798797042-3558267449-1001\Console\%SystemRoot%_SysWOW64_WindowsPowerShell_v1.0_powershell.exe]
"ColorTable05"=dword:00562401
"ColorTable06"=dword:00f0edee
"FaceName"="Lucida Console"
"FontFamily"=dword:00000036
"FontWeight"=dword:00000190
"PopupColors"=dword:000000f3
"ScreenBufferSize"=dword:0bb800ea
"ScreenColors"=dword:00000056
"WindowSize"=dword:003b00ea
"FontSize"=dword:00110000
"CursorType"=dword:00000000
"InterceptCopyPaste"=dword:00000000
"CursorColor"=dword:000000de


penpen

Re: Exporting two keys from Registry residing in two different places on Windows 10

Posted: 18 Jan 2023 14:14
by Compo
The first thing I thought, when I saw your question was...are you sure you need to do this?

Just in case you are unaware , the key HKCU is loaded from the relevant HKU\SID key at login time. It is very likely, unless you've just been messing around with your registry, that your own SID is S-1-5-21-3797103458-798797042-3558267449-1001. If that is the case you are simply trying to save two matching registry entries to the same file, which is pointless, as the unloading of HKCU upon logoff will save those entries back to the HKU\SID key. As soon as you log back on, those entries will match each other again.

There is a quick way for you to determine if there are any differences in the two locations, and that is by using the exact same utility you have used yourself, reg.exe:

Code: Select all

SystemRoot%\System32\reg.exe Compare "HKCU\Console" "HKU\S-1-5-21-4151016604-2149655897-3626235661-1001\Console" /S /OD
If you see something like this:

Code: Select all

Result Compared:  Identical
…then clearly there is no need whatsover to copy both to the one location, and you would only need to export HKCU\Console, or HKU\S-1-5-21-4151016604-2149655897-3626235661-1001\Console, depending upon the reason for your task in the first place.

There is also an added benefit to doing this first, you could change the /OD option to /ON, which would not output any differences message, and allow you to use the error codes:
  • 0 - Successful, the result compared is identical
  • 1- Failed
  • 2 - Successful, the result compared is different
…to determine whether you should copy both, copy just one, or something else.

Re: Exporting two keys from Registry residing in two different places on Windows 10

Posted: 21 Jan 2023 07:54
by DOSadnie
Compo wrote:
18 Jan 2023 14:14
[...]
are you sure you need to do this?
[...]
As there are multiple versions / settings of GUI for both CMD and PowerShell- yes

And no- prior to this I have not messed around in the Registry with CMD. I always was forced to apply changes manually, through settings, which was annoying whenever I had a new version of Windows installed or restored from an image after testing out some solutions / settings

This has been a long time issue for me - and finally I am able to export and import all of those that I know of [i.e. happen to be using]

Re: Exporting two keys from Registry residing in two different places on Windows 10

Posted: 21 Jan 2023 11:02
by Compo
You clearly didn't read my response. Please use the reg.exe command I offered, you will almost certainly see that both keys are identical, and therefore your entire question void.

Re: Exporting two keys from Registry residing in two different places on Windows 10

Posted: 15 Feb 2023 12:04
by DOSadnie
You are telling me about what should be - and I am telling how it is on my system, coming out from empirical data

I had a problem - I have it no more

Re: Exporting two keys from Registry residing in two different places on Windows 10

Posted: 16 Feb 2023 11:58
by Compo
Just because you are wrong, or your system is completely broken, does not mean that my advice is incorrect. Your HKEY_USERS\S-1-5-21-4151016604-2149655897-3626235661-1001 subkey is automatically mapped and mirrored, (a little like a junction / hard link), to HKEY_CURRENT_USER, when logged in. They are the same!