Loops in Action Script

There are 4 main ways I know of to do looping in ActionScript. (many of these have been pointed out above)

  1. Create a Fixlet/Task that addresses a single instance, and have it reapply
  2. Use relevance to create a batch file dynamically that addresses all of the instances at once
  3. Use 2 separate actions: one to determine what needs done, and another to do it.
  4. Have the Fixlet/Task run a script written in another language that can do actual looping

There are some instances where the looping issue can be avoided entirely, which are preferred if possible. For example, if you need to change the user registry, use Local GPO instead. See this example: http://bigfix.me/fixlet/details/3741

Here is an example of #1 above. This action will resolve the issue for the currently logged in user only. If this is taken as an open action applied to all endpoints, then if a new user logs in, this should run within a few minutes of that happening, which in this case is sufficient: http://bigfix.me/fixlet/details/3933

Here is an example of #2 above. This relevance will generate the contents of a BAT file that will delete all shortcuts on the Public Desktop for adobe products that were created during the action being executed. This was created to deal with installing Adobe Creative Cloud which would create an unknown number of Desktop shortcuts which could not be deleted by non-admins: http://bigfix.me/relevance/details/2999306


Here is a very complicated example of using relevance to create a file which contains an unknown number of items. This task actually downloads all tasks within a custom site, then it creates an XML representation of tasks which uninstall all MSI products found on the client that are not already existing within the custom site to prevent duplication. These tasks are then created using the REST API. This uses a secure parameter to send console credentials to the endpoint which is used to interact with the REST API. This is really an example of using relevance to generate a plural list of items to operate on, then using relevance to add to it in a very specific way. See the example here: http://bigfix.me/fixlet/details/3876

This is the idea in a simplified form:

("start: " & it & " :end") of ("abc";"def";"qwerty")

Which is actually more like this:

("start: " & it & " :end") of (it as string as trimmed string) of values "DisplayName" of keys whose(value "UninstallString" of it as string as lowercase contains "msiexec") of keys "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" of (x64 registries;x32 registries)
1 Like