NOTS3W Posted August 19, 2007 Posted August 19, 2007 Is there a way to set one registry value with the data from another within a cmd file?Here's what I have:HKEY_CLASSES_ROOT\.jpg (Default) REG_SZ original_default_dataHere's what I need:HKEY_CLASSES_ROOT\.jpg (Default) REG_SZ EmberImage BeforeEmberImage REG_SZ original_default_dataTo make the changes, I need to get the original data from the (Default) value possibly into an environment variable.REG QUERY HKCR\.jpg /ve returns too much information:! REG.EXE VERSION 3.0HKEY_CLASSES_ROOT\.jpg <NO NAME> REG_SZ NeroPhotoSnapViewer.Files.jpgI could also do this by renaming (Default) to BeforeEmberImage but I can't find a way to do that. REG COPY copies the entire key, not just the (Default) value.I'd really like to do this in a simple cmd file without getting into vbs scripts, etc. Any suggestions?Thanks.Ray
Yzöwl Posted August 19, 2007 Posted August 19, 2007 This is not a one size fits all solution.You cannot use this for all keys and values, many keys would require more values to be backed up and their structure would be different.Here is an NT command script, it uses as in your example REG.EXE, which is not available by default in any pre-XP Windows OS.@ECHO OFF&SETLOCALSET "N_=EmberImage"SET "K_=HKLM\SOFTWARE\Classes\.jpg"&SET "V_=Pre_%N_%"FOR /F "SKIP=3 TOKENS=2,3 DELIMS= " %%a IN ('REG QUERY %K_% /ve') DO ( SET "_=/t %%a /d "%%b"")ECHO:REG ADD %K_% /v %V_% %_%ECHO:REG ADD %K_% /ve /d "%N_%" /fPAUSEThe code does not contain sufficient checks/debugging for potential errors and is made only as an example to the questions originator. The code as is does not actually make registry changes, just echo's the potential changes to the console window.Note: DELIMS=<TAB> not a series of spaces!I hope it serves its purpose for you.
NOTS3W Posted August 21, 2007 Author Posted August 21, 2007 Thanks, Yzöwl. It's going to take me a bit to get my head around that, but I think I see what it does.Ray
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now