(imported comment written by JasonWalker)
My answer is similar to Gearoid’s but I do it a little bit differently. I think the best way to learn is to see several different ways of approaching the problem. This post is not to imply that Gearoid’s is wrong - just to show a couple of different examples.
ActionScript and Relevance are going to take some getting used to. With your programming background, you’ll almost need to “un-learn” some of your habits like include files, using loops, variables, etc.
If you haven’t read the Relevance Guides and ActionScript guides, I’d highly recommend them, as well as browsing www.bigfix.me for lots of examples and downloads.
In ActionScript, you can use Relevance Substitutions by enclosing the relevance in {} tags. A common technique, as demonstrated in the earlier posts, is to use ActionScript to build a Windows CMD file on the fly, using Relevance substitution for portions of it, and to then execute the batch file.
For what you’re doing, you should not need the “prefetch” command. Prefetch indicates to download a file (from your server, or from an external website). It’s the same as a Download command, except that Prefetch downloads the file before your action begins (so you can schedule an Action to occur later, but it will begin downloading the files it needs before the action starts).
For what you’re doing, you’d need a Task rather than a Fixlet. Both are similar, but a Fixlet is only considered “successful” if you have changed some condition that the Fixlet uses to determine its Relevance; so it can be found “Not Relevant” after it executes. A Task on the other hand is considered Successful if all of the ActionScript lines execute successfully.
For this Task, the relevance would probably be something simple like “windows of operating system” - which makes it relevant to all Windows machines.
The ActionScript could be something along the lines of
delete "__appendfile"
if {not exists folder "c:\ArchiveData"}
appendfile mkdir c:\ArchiveData
endif
// The following line builds a series of xcopy strings, one for each Profile Folder of User found. These are concatenated with
// %0d%0a -- the DOS/WIndows "Carriage Return / Line Feed" pair - so they end up as multiple lines in __appendfile
// The Paths are wrapped in %22 - the doublequote character.
// Note that since BigFix is doing the copying, the target files will be owned by SYSTEM. If you want the source permissions preserved,
// adjust the XCOPY parameters appropriately.
appendfile {concatenation "%0d%0a" of ("xcopy /E /I /Y /D %22" & it & "%22 %22c:\ArchiveData\" & following text of last "\" of it & "%22") of profile folders of users}
// move / copy ActionScript will fail if the target file already exists - so make sure it doesn't
delete "BackupDesktops.cmd"
// move our generated __appendfile to a .CMD file
move __appendfile BackupDesktops.cmd
// Execute the .CMD file, without displaying it, and wait for execution to complete
waithidden cmd /c BackupDesktops.cmd
My version doesn’t relay on C:\Users being the path - it should work the same for C:\Users, C:\Documents and Settings, or C:\Profiles, as have been used in different versions of Windows. It also won’t copy the Default User or All User desktops, and it won’t try to copy obsolete profiles for users who have been deleted.