MFCOM Script to List Applications Only in Specified Folders


MFCOM Script to List Applications Only in Specified Folders

Here is a quick MFCOM script to list all the published applications and folders in a specified folder or folders. There are two options for using the script. Option one takes any number of command line arguments. Each command line argument represents a folder name. Option two takes no command line arguments and relies on hard-coded folder names within the script.

Suppose you had the following tree structure for your published applications:


Now, say you wanted to run a script that only returned applications in the Testing folder and Microsoft Applications folder. To accomplish this, run the following at a command prompt: 

cscript //Nologo GetAppsInFolders.wsf  “Testing” “Microsoft Applications”

The above command produces the following results:

Note that every folder specified is a child of the “Applications” folder.  To specify a folder that is not a child of the “Applications” folder, you must specify the path relative from “Applications”.  For instance, if you wanted to get only the applications published in the “New Folder” under “Testing”, run the following command:

cscript //Nologo GetAppsInFolders.wsf  “Testing/New Folder”

The above command produces the following results:

To set up the hard-coded folders, open the script in a text editor and look for the following lines (starting around line 31):

    ' If no command line arguments, use hard-coded folders
    if  WScript.Arguments.Count = 0 Then
        ReDim arrFolders(2)
        arrFolders(0) = "Testing"
        arrFolders(1) = "Microsoft Applications"

Change ReDim arrFolders(2) to ReDim arrFolders(x) where x represents the number of folders you want to hard code.
Next, add arrFolders(n) = “Folder Name” for each folder you want to hard code (where n is a distinct number between 0 and x).

So what is all this good for anyway?  Suppose you wanted to export applications in a few select folders, then import those applications in to a different farm.  This Citrix article demonstrates how to use EXPORT and NEWAPP from the Citrix APSDK.  Using EXPORT and NEWAPP along with GetAppsInFolders.wsf, you can export bulk applications from select specified folders and then import those applications into a different farm.

8 thoughts on “MFCOM Script to List Applications Only in Specified Folders

  1. U jason don’t wanna be a spoiler but pat.exe already does it all? It exports the total farm and you can create your own .app files.

    But heck if this goes faster I really gonna give it a try cause every new tool is welcome 🙂

    Hans Straat

  2. There are times when you don’t want to export the details of all the apps in the farm and just the contents of a particular folder.

    This script is something I have been looking for for a while. Thanks

    Now to work out how to redirect it to Export.exe….

  3. Your script doesn’t work correct if the given folder hast multiple subfolders. In my case the output string grew with each subfolder, as the script added each new subfolder string to the previouse rootfolder\subfolder string. This resulted in continiously growing strings. (rootfolder\subfolder1\subfolder2\..\subfoldern)
    It worked fine after i commented out line 108 (strPath = strPath & folder.FolderName & "/")

  4. Correction: Simply commenting out the line i mentioned seemd to solve the issue but in fact it didn’t list some subfolders at all.

    What worked was this:
    strPath2 = strPath & folder.FolderName & "/"
    Of course strPath2 has to be declared and used as a parameter later on.

Leave a Reply

Your email address will not be published. Required fields are marked *