FSCOMMAND "exec" and Subfolders

Posted by Aaron West at 2:05 PM in Flash

The fscommand command in Flash gives developers the ability to run virtually any Windows application that resides on a client machine. You do this using the "exec" command that you pass through the fscommand construct. Macromedia uses this functionality in their installer for StudioMX and StudioMX 2004. (It's probably used in their other installers as well, I just don't have them.) You can imagine how useful this is for creating custom, Flash-based software installers, but the road doesn't end there. I recently had the need to create a Flash projector file that had the ability to launch any kind of executable content. Mainly Flash and Authorware content built into projectors. At the same time, I needed to retain the directory structure that each of the content pieces relied on. This produced a problem. First of all, fscommand expects all executables to be located in a folder called, you guessed it, "FSCOMMAND." (Case doesn't matter on Windows.) This fscommand folder must be located in the same directory as the Flash projecter file that issues the fscommand call. There's only one problem with this scenario. You cannot create subfolders within the fscommand folder and call executables in those subfolders. It just doesn't work. The solution is to create a batch file (.bat) and have your fscommand "exec" each batch file living in the root of the fscommand folder. Here's what I have working:

root folder contains (we'll call this /root):


/root/FSCOMMAND/ folder contains:

- many subfolders; for example purposes, let's refer to a folder called /nameaddress.

- our batch file; for easy recognition we'll name our batch file nameaddress.bat since it will execute a file in /nameaddress.

Here's the batch file (/root/FSCOMMAND/nameaddress.bat):

@echo off

start nameaddress/nameaddress01.exe


So, our batch file is obviously calling the nameaddress01.exe executable located in the /root/FSCOMMAND/nameaddress folder.

The code in the projecter (launcher.exe) that calls the batch file looks like this:

_root.launch_btn.onRelease = function() {

   fscommand("exec", "nameaddress.bat");


Notice how the path parameter does not explicity refer to the fscommand folder. It's inferred by Flash. So, to clarify, the final file/directory layout looks like this:




Aaron West's Gravatar
About this post:

This entry was posted by Aaron West on October 29, 2003 at 2:05 PM. It was filed in the following categories: Flash. It has been viewed 11476 times and has 8 comments.

8 Responses to FSCOMMAND "exec" and Subfolders

  1. Mitoo

    Great! Just what I needed.... on April. 2006. You never know when a post is going to make itsel useful.. Thanks a lot.

  2. Mitoo, thanks for the comment. I'm glad you found this post useful.

  3. Tracy

    I also wanted to say thanks, this helped me also solve a problem I was having. Much appreciated! =) Tracy

  4. Alisic

    Woo! Thanks much! You saved my behind! The macromedia documentation is very vague on fscommand exec, glad to have come upon this post. I'm subscribing to your RSS, hehe.

  5. First of all thank you Aaron West for posting this, I read too
    many tutorials about the fscommand, but none of them were
    helpful. But here I found the solution. Thank you once again.
    My bow for you.

  6. ktfung

    :::how about running something like this
    :::jsave.exe take two parameter
    e.g run in command prompt
    c:\>jsave temp.txt hello_world

    (note: Jsave.exe will create temp.txt and write hello_world inside the text file.)

    :::partially Flash MX code
    var text="jsave.exe temp.txt hello_world";

    i cant seem to run the code above in executable projector build from .fla file.

  7. Marko

    I have trouble with my folder structure, take a look:


    what to do!!!

  8. Molly

    Thank you so much, I needed to finish a list minute job and this helped me so much! Everything else I looked up didn't work, you saved my ass, thank you!!!!!