Using Parameters

(imported topic written by Edj)

I am currently attempting to create a task that would check for the existing of a file and create a registry entry based on its findings. I would like to create a Parameter (variable) if the file exists and store this parameter to be used in the creation of the registry key. I am running into an issues getting this to work. Does anyone have any Ideas or Examples of this.

Thanks

Edj

(imported comment written by brolly3391)

Welcome to the forum Edj,

Use relevance to check for the existance of your value and action {relevance substitution} to use that value in the action script.

In a general sort of way, here is relevance and action for a task that sets registry value HKEY_LOCAL_MACHINE\Software\BigFix tempvalue to the first line of the file myfilename.txt in folder c:\program files\my test application as long as the folder exists and the file exists and there is a first line in the file.

relevance

exists folder “c:\program files\my test application” whose (exists file “myfilename.txt” whose (exists line 1 of it) of it) AND

insert other relevance here

action

regset "

HKEY_LOCAL_MACHINE\Software\BigFix

" “tempvalue”="{line 1 of file “myfilename.txt” of folder “c:\program files\my test application” as string}"

I hope that is a good start. If you find yourself having troubles getting it to work then give us a little bit of background on your goal.

Cheers,

Brolly

(imported comment written by Edj)

Thanks Brolly,

This will help. I also would like to ask another question in regards to this property.

I would also like to perform an additional task such as:

relevance

if (exists file “Branch.txt” of windows folder) then "“CompID” = {Branch} else if (exists file “Store.txt” of windows folder) then "“CompID” = {store} else “CompID” = {UnKnown}

action

regset "

HKEY_LOCAL_MACHINE\SOFTWARE\Company

" “ID”="{CompID}"

I cannot seem to get this right.

Thanks,

Edj

(imported comment written by brolly3391)

Hey Edj,

Thanks for the additional detail.

You are so close. You just need to move that if/then/else into the action using {relevance substitution}. In case both files are present, the first If will take precedence and you will get Branch.

The relevance is unneeded in this case and could be anything you wanted. Since we are using Windows Folder we might want to limit this task to only windows machines.

Relevance:

name of operating system as lowercase starts with “win”

Action:

regset "

HKEY_LOCAL_MACHINE\SOFTWARE\Company

" “ID”="{

if (exists file “Branch.txt” of windows folder) then “Branch” else if (exists file “Store.txt” of windows folder) then “Store” else "Unknown

}"

Cheers,

Brolly

(imported comment written by Edj)

Brolly,

Excellent! Your Action worked perfectly.

I just had to add an (") after the

else "Unknown

Thanks,

Edj

(imported comment written by Marjan23)

Edj,

Just as a note, you have the ability to add parameters in your action script (in BES 6.0). You can do this with the following syntax:

parameter “x” = {some relevance here}

and you can call that parameter later on in the script, for example:

run {parameter “x”}

In your case you could have done something like this:

parameter “x”= {if (exists file “Branch.txt” of windows folder) then “Branch” else if (exists file “Store.txt” of windows folder) then “Store” else “Unknown”}"

regset "

HKEY_LOCAL_MACHINE\SOFTWARE\Company

" “ID”={parameter “x”}

However this is only useful if you are going to use this parameter multiple times. Otherwise, a solution provided by Brolly seems much more reasonable.

Hope this helps in the future,

Marjan

(imported comment written by SystemAdmin)

Marjan

However this is only useful if you are going to use this parameter multiple times

I would argue that it makes it more legible too… :cool: