Action Script.. Fill a parameter with value from registry

Hi BigFix forum members,

I am trying to write an action script that reads the value from the Registry and puts that in a parameter.
All the statements that I tried keep on failing on the actual statement.

Using the key value in an IF statement is not an issue, but I need the value of that key later in the script.

Is it even possible to use variables from outside the script, while running the script?

This is the option I tried:

parameter "IPSetting"=(value "IPSetting" of key "HKEY_LOCAL_MACHINE\SOFTWARE\Installation\" of native registry)

I did try other notations (with and without curley brackets. less or more brackets; value of key of registry etc. But the statement that work in the IF statements

if  (value "IPSetting" of key "HKEY_LOCAL_MACHINE\SOFTWARE\Installation\" of native registry=1) then

Does not carry over into a Parameter command

I’d love to hear it;

Alex van den Bos

Hi Alex,

I think you just have to surround your right side of the parameter with curly brackets and quotes. This works for me:

parameter "IPSetting"="{value "IPSetting" of key "HKLM\Software\Installation\" of native registry}"

2 Likes

The only thing I did not try was putting it in both Curly braces and “” … and that’s what does the trick

Thanks for also letting me see that I can actually use the fixlet debugger to try this out. I was constantly pushing the task to see if it ran or not…

made my day!

1 Like

I have a similar issue…
Im trying to assign a registry location to a parameter and in the action script , set that location to a new value… So the action script I have is this.

parameter “Card” = “{{name of (keys of keys “HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class{{4d36e972-e325-11ce-bfc1-08002be10318}” of registry) whose (exists values whose(name of it = “PnPCapabilities” AND it as string as lowercase = “0” as lowercase ) of it)}”

regset [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class{{4d36e972-e325-11ce-bfc1-08002be10318}{(parameter “Card” of action)}]" “PnPCapabilities”=dword:00000018

The output in the Debugger is showing the exact line instead of returning 0001 in my case…

In actual fact,. what Im trying to do is turn off the ability of Windows to shut down the ethernet card and thats the PnP bit in the registry that toggles from 0 (default) to 18 hex (24Dec) wen its disabled

You double-up the open curly brackets to escape the relevance substitution (to prevent substitution and use the literal open-curly symbol). That’s correct in the regset command, where you need {guid} literally as part of the registry key, but not in the line where you’re defining the parameter.

There, you need to not double-up the open curly at the beginning, nor at the start of the classguid. Instead, you need to double the close-curly at the end of classguid (to not end the relevance substitution). It also looks like you’re missing the backslash at Class{guid}

Try

parameter "Card" = "{name of (keys of keys "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class\{4d36e972-e325-11ce-bfc1-08002be10318}}" of registry) whose (exists values whose(name of it = "PnPCapabilities" AND it as string as lowercase = "0" as lowercase ) of it)}"

You may have issues where there is more than one NIC though. In that case you may find it easier to do

delete __appendfile
appendfile {concatenation "%0d%0a" of ("reg.exe add %22" & pathname of it & "%22 /v PnPCapabilities /t REG_DWORD /d 24 /f") of pathnames of keys whose (value "PnPCapabilities" of it as integer != 24) of keys  "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class\{4d36e972-e325-11ce-bfc1-08002be10318}}" of registry}
move __appendfile UpdateReg.cmd
waithidden cmd.exe /c UpdateReg.cmd
1 Like