0

How can I query a registry and save it to a variable inside of a makefile? I am using GNU Make.

VARIABLE = reg query "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" /f /v VAR

PRINT:
    @echo $(VARIABLE)

SET:
    reg add "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" /f /v VAR /t REG_SZ /d "VALUE"

1 Answers1

0

reg is writing its result to the standard output (so that the results can be redirected to a file, e.g., this line in a batch file

set myvar = reg query "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" /f /v VAR

You can take the same output and read it into a variable using GNU make, e.g., this line in a makefile

myvar = $(reg query "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" /f /v VAR)

Further reading:

Community
  • 1
  • 1
Thomas Dickey
  • 51,086
  • 7
  • 70
  • 105