Command Need for Reg Key ADD using Command line

Hi Team,

I am trying to execute the below reg key using command line with administrator account and it is executing with out any error

But while using Bigfix Registry wizard I am getting the small error like below.

For example while running over command prompt the below reg key value automatically updating the computer name(host anme) in reg key value field.

reg add HKLM\Software\Candle\KNT\Ver610\Primary\Environment /t REG_EXPAND_SZ /v CTIRA_SYSTEM_NAME /d “%COMPUTERNAME%” /f

but using Bigfix Reg key wizard mean it is not updating the actual computer name(host name) in value and it is giving like below

is there any other command to update the actual host name in reg value

Thanks,
Nagaraj.

I’d be more inclined to use regset or regset64 because if you want to have the real value in there and not the environment variable then you can store it as a REG_SZ - no need for REG_EXPAND_SZ.

However, you are putting the environment variable in quotes - you can see them in your regedit screenshot. Take the unnecessary quotes away and it will work.

I have tried with out “” quotes also but it is not updating the computer (host name ) in value.

Is there any bigfix action script to add the computer host name in reg key value place ?

regset64 "[HKEY_LOCAL_MACHINE\Software\Candle\KNT\Ver610\Primary\Environment]" "CTIRA_SYSTEM_NAME"="{computer name}"

1 Like

It is working but Reg key type is different.

Instead of “REG_EXPAND_SZ” it is creating “REG_SZ”

I want to create reg key type as “Expandable string value”.

Why do you want REG_EXPAND_SZ to store a literal? REG_EXPAND_SZ is used to expand an environment variable to its value - not needed here because you said you wanted to store the literal computer name.

If you insist on it being REG_EXPAND_SZ, and the expansion, you need to obey all the rules and append a null character to the stored string. To do this you will need to use the reg command directly or via a .reg file that you create.

See https://docs.microsoft.com/en-us/windows/win32/sysinfo/registry-value-types if you need explanation of the different registry value types.

Application will work while we create “REG_EXPAND_SZ” only, I am trying to add this command using bigfix action script.

because now OS team doing manually in each machines using command prompt. so we want to do BigFix with the same task.

is there any option to edit the existing key value “REG_EXPAND_SZ" using bigfix action command?

Export a known good version to a .reg file.
Trim out any values you don’t want o affect.
Upload the .reg file.
Create a fixlet or task that downloads the .reg file and use reg.exe to import it.

Yeah but I have to deploy 50+ different servers, so if I export and import the Hostname (reg key value )will not be change may be.

Is that correct ?

Just use the export to get the syntax of a reg_expand_sz value.

Then use createfile to build it on the fly, with a {computer name} Substitution for the computer name.

1 Like

@JasonWalker could you please help any example for create file option with exported reg file.

@trn If i use below script mean, it will create the correct key type in “HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node”

wait cmd.exe /C reg add HKEY_LOCAL_MACHINE\Software\Candle\KNT\Ver610\Primary\Environment /t REG_EXPAND_SZ /v CTIRA_SYSTEM_NAME /d %COMPUTERNAME% /f

here any script to create the key in “HKEY_LOCAL_MACHINE\SOFTWARE”

this one working as I expected the reg key type “REG_EXPAND_SZ” with computer actual host name.

action uses wow64 redirection false
wait cmd.exe /C reg add HKEY_LOCAL_MACHINE\Software\Candle\KNT\Ver610\Primary\Environment /t REG_EXPAND_SZ /v CTIRA_SYSTEM_NAME /d %COMPUTERNAME% /f

thanks @trn @JasonWalker.

1 Like