Help with action script - Grab a registry value and put in variable of action script

I have registry key - {value “UserFolder” of key “HKEY_CURRENT_USER\Software\Microsoft\OneDrive\Accounts\Business1” of registry} - get it value data and put in a variable in action script.

----script----
parameter “baseFolder” = "{value “UserFolder” of key “HKEY_CURRENT_USER\Software\Microsoft\OneDrive\Accounts\Business1” of registry}

createfile until UBackupDrive
@echo on
mklink /d “{parameter “baseFolder”}UBackupDrive” "U:"
UBackupDrive

waithidden cmd.exe /C del /f /s /q "C:\um\OneDrive_UBackupDrive.bat"
waithidden cmd.exe /C copy /Y __createfile “C:\um\OneDrive_UBackupDrive.bat”

You could user something like

value "UserFolder" of key "Software\Microsoft\OneDrive\Accounts\Business1" of user key of logged on user

but you should also ensure to include checks for a logged on user. The relevance substitution would fail if no user was logged in, or it more than 1 user was logged on so including a check such as number of logged on users = 1 in the fixlet applicability would prevent the fixlet from being relevant of none or more than 1 user was logged on.

Alternatively you bypass the dependency for a logged in user and look in all keys under HKU then perform the action on all user keys where the value exists. Bear in mind this will return a plural result than may contain 1 or more answers

values "UserFolder" of key "Software\Microsoft\OneDrive\Accounts\Business1" of keys of key "HKU" of registry

Thank you SLB.
I am using the below parameter and it works
Parameter “Onedrivefolder” = “{value “UserFolder” of key “Software\Microsoft\OneDrive\Accounts\Business1” of current user keys (logged on users) of registry}”

1 Like

Hi SLB,

I have an action script question. I’m trying to create a fixlet to verify some settings on my servers and the last part of my action script regarding the relayserver2 i’m not sure is coded correctly (Desire: regard if setting exist would want to verify that RelayServer2 is set to my “NJBFRELAY2”)

// Enter your action script here
// Enable Command Polling if not enabled
if { not exists settings “_BESClient_Comm_CommandPollEnable” whose( (it = 1) of (it as string as integer) of values of it ) of client }
setting “_BESClient_Comm_CommandPollEnable”=“1” on “{parameter “action issue date” of action}” for client
endif

// This will set command polling to once every 6 hours, if not already enabled more aggressively
if {not exists settings “_BESClient_Comm_CommandPollIntervalSeconds” whose( (it <= 43200) of (it as string as integer) of values of it ) of client}
setting “_BESClient_Comm_CommandPollIntervalSeconds”=“21600” on “{parameter “action issue date” of action}” for client
endif

if {not exists settings “_BESClient_Download_MinimumDiskFreeMB” whose( (it >= 2000) of (it as string as integer) of values of it ) of client}
setting “_BESClient_Download_MinimumDiskFreeMB”=“2000” on “{parameter “action issue date” of action}” for client
endif

if {not exists settings “_BESClient_Download_DownloadsCacheLimitMB” whose( (it >= 2000) of (it as string as integer) of values of it ) of client}
setting “_BESClient_Download_DownloadsCacheLimitMB”=“2000” on “{parameter “action issue date” of action}” for client
endif

if {not exists settings “_BESClient_Download_NormalStageDiskLimitMB” whose( (it >= 8096) of (it as string as integer) of values of it ) of client}
setting “_BESClient_Download_NormalStageDiskLimitMB”=“8096” on “{parameter “action issue date” of action}” for client
endif

if {not exists settings “_BESClient_Download_PreCacheStageDiskLimitMB” whose( (it >= 8096) of (it as string as integer) of values of it ) of client}
setting “_BESClient_Download_PreCacheStageDiskLimitMB”=“8096” on “{parameter “action issue date” of action}” for client
endif

if {not exists setting “Site” whose( (it = 0) of (it as string as integer) of values of it ) of client}
setting “Site”=“Somerset” on “{parameter “action issue date” of action}” for client
endif

if {exists setting “__RelayServer2” whose( (it = 0) of (it as string as integer) of values of it ) of client}
setting “__RelayServer2”=“http%3a%2f%2fNJBFRELAY2%2ecorp%2elocal%3a52311%2fbfmirror%2fdownloads%2f” on “{parameter “action issue date” of action}” for client
endif

// force a relay selection
relay select

notify client ForceRefresh

Your "__RelayServer2" logic is only going to be processed if the value as an integer 0, which I very much suspect will never be the case so its not going to get processed. I’d be using the approach more like

if{not exists setting "__RelayServer2" whose (value of it = "http://relay.mydomain.com:52311/bfmirror/downloads") of client} 
setting "__RelayServer2"="http://relay.mydomain.com:52311/bfmirror/downloads" on "{parameter "action issue date" of action}" for client
endif

You may also need to set "__Relay_Control_Sever2"

if{not exists setting "__Relay_Control_Server2" whose (value of it = "http://relay.mydomain.com:52311/bfmirror/downloads") of client} 
setting "__RelayServer2"="http://relay.mydomain.com:52311" on "{parameter "action issue date" of action}" for client 
endif

Thank you, I’ve updated as per your advise to:

if {not exists setting “__RelayServer2” whose (value of it = “http://bigfix1.corp.local:52311/bfmirror/downloads”) of client}
setting “__RelayServer2”=“http://NJBFRELAY2.corp.local:52311/bfmirror/downloads” on “{parameter “action issue date” of action}” for client
endif

if {not exists setting “__Relay_Control_Server2” whose (value of it = “http://bigfix1.corp.local:52311/bfmirror/downloads”) of client}
setting “__RelayServer2”=“http://NJBFRELAY2.corp.local:52311/bfmirror/downloads” on “{parameter “action issue date” of action}” for client
endif

You may want to check your “Site” setting to, which is also comparing a string value of the setting to a numerical 0

You’re right and updated to:

if {not exists setting “Site” whose (value of it = “”) of client}
setting “Site”=“Somerset” on “{parameter “action issue date” of action}” for client
endif