Coucher Posted August 19, 2009 Posted August 19, 2009 I have a need to update a specific registry key with the current date on the first boot of the machine after it is imaged.Additionally, one issue is that the slashes have to be reversed. For example, if the date is 08/16/2009, the registry key needs to be updated to 08\16\2009.What I'm visualizing is this:A bat file of some sort that is set to run once on the first boot.The bat file would somehow query for the current date, then create a reg file replacing the "/"s with "\"s.Then execute the merging of the created reg file by invoking REGEDIT.EXE /S importfile.REGThis is just what I'm envisioning. If there's a better way, I'm definitely open to suggestions.If it matters, this is what the created reg file with the current date would need to look like:Windows Registry Editor Version 5.00[HKEY_LOCAL_MACHINE\SOFTWARE\PGP-IGA][HKEY_LOCAL_MACHINE\SOFTWARE\PGP-IGA\PREP]"INSTALLDATE"="08\16\2009"Thanks in advance for any help, assistance or advice!
Yzöwl Posted August 19, 2009 Posted August 19, 2009 Would this do for what you need?REG ADD HKLM\SOFTWARE\PGA-IGA\PREP /V INSTALLDATE /D "%DATE:/=\%" /F>NUL
Coucher Posted August 20, 2009 Author Posted August 20, 2009 Would this do for what you need?That is actually VERY close, however the key it created/updated has "Thu 08\20\2009" rather than "08\20\2009"
Yzöwl Posted August 20, 2009 Posted August 20, 2009 You'll need to create the value string in your batch file first then.Try either:@ECHO OFFFOR /F "TOKENS=2-4 DELIMS=/ " %%A IN ('DATE /T') DO ( REG ADD HKLM\SOFTWARE\PGA-IGA\PREP /V INSTALLDATE /D "%%A\%%B\%%C" /F>NUL)Or:@ECHO OFFFOR /F "TOKENS=2-4 DELIMS=/ " %%A IN ("%DATE%") DO ( REG ADD HKLM\SOFTWARE\PGA-IGA\PREP /V INSTALLDATE /D "%%A\%%B\%%C" /F>NUL)
Coucher Posted August 20, 2009 Author Posted August 20, 2009 Just to update in case anyone ever comes across the post while searching, I added the "del %0" command to the end to have the bat file self delete after running.Works just as it should. Bat file runs, then deletes itself.@ECHO OFFFOR /F "TOKENS=2-4 DELIMS=/ " %%A IN ('DATE /T') DO ( REG ADD HKLM\SOFTWARE\PGA-IGA\PREP /V INSTALLDATE /D "%%A\%%B\%%C" /F>NUL)del %0
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now