AS3: How to Run Applications from a Flash Projector EXE with Actionscript 3 and Batch Files

So i’ve been writing some CD launchers recently with some handy tools on. One thing i had major trouble with was getting a Projector .exe to run programs from sub directorys. Luckily i figured it out :) so heres how…

First in your CD/DVD root directory place a folder named “fscommand” this is the only folder which the projector will be able to see (from my experience, though there are some other methods about).

011

Then within your “fscommand” folder create a batch file (just create a .txt file and rename to .bat). I called mine “RUN.bat”.

021

Now right-click on the bat file and select “edit” (this will open the batch file with notepad).

now we need to put in some code.

Here is my example:

@echo off

start "" "../programs/ProcessExplorerNt/procexp.exe"

@exit

This path is relative to the “fscommand” folder (../ going up a directory to our root).

Now in your FLA actions layer:

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

This will simply look into the “fscommand” folder and execute the bat file, which in turn will run our program.

also note that you must publish to Windows Projector (in your publish settings) and run the exe to test “fscommand”, ctrl + enter wont work here.

Hope this helps.

Stay Cool

-Bill

Tags: , , , , , , ,

  • Panda

    thank you very much!
    this is EXACTLY what I was searchin for.

  • http://www.bigtallbill.co.uk Bill Nunney

    Glad i could help, This one gave me major headaches to figure out :p

  • mando

    Creative>>>>>>>>>>>>>>>>>>>>

    Thanks

  • xdeath

    if i were to runa batch file using fscommand, would it return the results to flash? and if i wanted to send the results to a variable i’d just say “variable = fscommand(“run.bat”);” yes?

  • http://www.nocolor.ir dani

    Hello, Thank you.
    but when i use (..) for up to root folder in batch file, there is no action.
    so I’m using this:
    @echo off

    start “” “/1/1.exe”

    @exit

    also We can use this for open pdf files with adobe reader.
    if we use getURL, flash open pdf in to default web browser, this is not professional work, but when flash use a .bat file it will open in a single file.

    thank you for your script.
    regards,
    Dani Day Helm

  • Ahmad

    Hello.
    This is a good idea, but it does not work in windows 7!
    It’s a very big problem for me and I can’t solve it.

  • http://www.ksepions.zxq.net krishntha

    Hi,

    thanks lot for your sharing.

    it’s help my work done.

  • sandeep kumar

    Thanks, you saved my a lot of time.
    Thanks alot.

  • Rajdeep

    thnx man you are a killer!! I was wondering if it was possible