There are many ways to write the registry. I usually use the methods of echo>> and the REG command.
The following is a segment of code I wrote for operating the registry when creating the green version of ACCESS 2003.
REM Set registry 1. Set the application path so that the program can be executed in the command line. Here, the method of importing and generating and importing the registry is used
ECHO REGEDIT4 >>APPPaths.REG
ECHO. >>APPPaths.REG
ECHO [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\MSACCESS.EXE] >>APPPaths.REG
ECHO @="%CPATH%\\MSACCESS.EXE" >>APPPaths.REG
ECHO "Path"="%CPATH%\\" >>APPPaths.REG
ECHO "useURL"="1" >>APPPaths.REG
regedit /s APPPaths.REG >NULL
del APPPaths.REG /q/f >NULL
cls
REM Set registry 2. Set the product registration authorization information of the application, otherwise the software cannot be used. Here, the REG method is used
REG ADD "HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Licenses\73A4C9C1-D68D-11d0-98BF-00A0C90DC8D9\11.0\Retail" /F
REG ADD "HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Licenses\73A4C9C1-D68D-11d0-98BF-00A0C90DC8D9\11.0\Retail" /ve /t REG_SZ /d sbbcdcprktpjtapmmfdacmupasbhscddncgp /f
cls
REM Set registry 3. Set the VBA path, otherwise the VBE editing program cannot be used for secondary development. Here, the REG method is still used. Note that when using variables, use "" to enclose them. The help says to use %% which is incorrect
REG ADD "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VBA" /F
REG ADD "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VBA" /v "Vbe6DllPath" /t REG_SZ /d "%CommonProgramFiles%"\MICROS~1\VBA\VBA6\VBE6.DLL /f
cls
REM Set registry 4. Set the software registry information, generally the registry item under the software name
binsub office.REG E:\\OFFICE2003\\OFFICE11\\ %CPATH%\\ >NULL
binsub office.REG C:\\ %SystemDrive%\\ >NULL
regedit /s office.REG >NULL
del office.REG /q/f >NULL
CHCP 936 >NULL
cls
REM Set registry 5. Set file association. Here, it can also be implemented using FOR. Note that version 1.8 of BINSUB supports at most 127 characters. The problem has been solved in version 2.1.
binsub link.reg E:\\OFFICE2003\\OFFICE11\\ %CPATH%\\ >NULL
binsub link.reg C:\\ %SystemDrive%\\ >NULL
regedit /s link.reg >NULL
del link.reg /q/f >NULL
CHCP 936 >NULL
cls
REM Set registry 6. Create the language setting add-in Language.mda. After setting, the ACCESS interface language can also be set through the language setting add-in
REG ADD "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\11.0\Access\Menu Add-Ins\&Language Setting" /F
REG ADD "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\11.0\Access\Menu Add-Ins\&Language Setting" /v "Expression" /t REG_SZ /d "=LangSet()" /f
REG ADD "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\11.0\Access\Menu Add-Ins\&Language Setting" /v "Library" /t REG_SZ /d "Language.mda" /f
REM Set registry 7. Add the built-in controls and enhanced controls for advanced development.
REM Removed OWC11.DLL MSRTEDIT.DLL, REFEDIT.DLL and other controls. They can be added when needed
REM First register the SNAPVIEW.OCX snapshot file, which has been extracted in profile.exe first.
regsvr32 /s "%CommonProgramFiles%\Micros~1\Snapsh~1\SNAPVIEW.OCX"
REM Register built-in controls and enhanced controls
plugin.exe
REM Barcode control
copy plugin\MSBCODE9.OCX ..\ /Y >NULL
regsvr32 /s ..\MSBCODE9.OCX
REM Calendar control MSCAL.OCX, where Mscomct2.ocx is a better calendar control
copy plugin\MSCAL.OCX ..\ /Y >NULL
regsvr32 /s ..\MSCAL.OCX
copy plugin\Mscomct2.ocx ..\ /Y >NULL
regsvr32 /s ..\Mscomct2.ocx
REM form2.0 control
copy plugin\FM20.DLL %WINDIR%\SYSTEM32\ /y >NULL
regsvr32 /s %WINDIR%\SYSTEM32\FM20.DLL
REM VSFLEX3.0 control
copy plugin\VSFLEX3.OCX %WINDIR%\SYSTEM32\ /y >NULL
regsvr32 /s %WINDIR%\SYSTEM32\VSFLEX3.OCX
REM Public component latest control 6.0: mscomctl.ocx (the 5.0 one is comctl32.ocx, not used here), need authorized registration
copy plugin\mscomctl.ocx %WINDIR%\SYSTEM32\ /y >NULL
regsvr32 /s %WINDIR%\SYSTEM32\mscomctl.ocx
REM Public dialog latest control 6.0: COMDLG32.OCX, need authorized registration
copy plugin\COMDLG32.OCX %WINDIR%\SYSTEM32\ /y >NULL
REM Serial port programming latest control 6.0: Mscomm32.ocx, need authorized registration
copy plugin\Mscomm32.ocx %WINDIR%\SYSTEM32\ /y >NULL
regsvr32 /s %WINDIR%\SYSTEM32\Mscomm32.ocx
REM Text editing latest control 6.0: RICHTX32.OCX, need authorized registration
copy plugin\RICHTX32.OCX %WINDIR%\SYSTEM32\ /y >NULL
regsvr32 /s %WINDIR%\SYSTEM32\RICHTX32.OCX
REM Table latest control 6.0: MSFLXGRD.OCX, need authorized registration
copy plugin\MSFLXGRD.OCX %WINDIR%\SYSTEM32\ /y >NULL
regsvr32 /s %WINDIR%\SYSTEM32\MSFLXGRD.OCX
REM Network latest control 6.0: Mswinsck.ocx, need authorized registration >NULL
copy plugin\Mswinsck.ocx %WINDIR%\SYSTEM32\ /y
regsvr32 /s %WINDIR%\SYSTEM32\Mswinsck.ocx
regedit /s PLUGINS.REG >NULL
del PLUGINS.REG /q/f >NULL
RD plugin /Q/S >NULL
CLS
REM Create the shortcut of the program running: desktop, quick launch bar, program menu. Here, the LEELINK tool is used. Before creating, the CPATH environment variable needs to be changed (can be implemented using COPY method)
CALL CPTEMP.bat
SLINK /F:%CPATH%\MSACCESS.EXE /C:Microsoft Office Access 2003 /s:y /d:y
del slink.exe /q/f >NULL
rem ================================================================
rem cd ..
rem copy Micros~1.lnk "%ALLUSERSPROFILE%\桌面\ /Y"
rem copy Micros~1.lnk %ALLUSERSPROFILE%\桌面\「开始」菜单\ /Y
rem copy Micros~1.lnk %ALLUSERSPROFILE%\桌面\「开始」菜单\程序 /Y
rem cd STARTUP\
rem ================================================================
cls