Jump to content

Recommended Posts

Posted

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.REG

This 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!


Posted
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"

Posted

You'll need to create the value string in your batch file first then.

Try either:

@ECHO OFF
FOR /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 OFF
FOR /F "TOKENS=2-4 DELIMS=/ " %%A IN ("%DATE%") DO (
REG ADD HKLM\SOFTWARE\PGA-IGA\PREP /V INSTALLDATE /D "%%A\%%B\%%C" /F>NUL)

Posted

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 OFF
FOR /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

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...