FSCommand EXEC is Broken in Flash CS3

 Posted on Tue Aug 14 2007 in Flash by Tim

For years Flash has allowed any valid Windows executable to be launched via fscommand EXEC from a Flash projector. That has come to an end with Flash CS3. Flash 9 projectors fail to launch BAT files on Windows 2000, XP and Vista but it still works on Windows 98 and ME! This is major inconvenience but it's not the end of the world. First I'll show you why it's broken, then I'll show you how you can still launch BAT files from your Flash projectors, with a little help...

On NT based systems (2000, XP and Vista) Flash 9 projectors now create child process with a UNC path instead of a simple DOS path as all previous versions of the standalone player have done. The resulting error when you launch a BAT file appears for a fraction of a second but I managed to capture it.



Why is Flash trying to launch CMD.EXE when we asked it to start a BAT file? CMD.EXE is the Windows command processor that handles BAT files. When ever you run a BAT file Windows starts a copy of CMD.EXE to handle it. It's CMD.EXE that's responsible for the ugly DOS box you see when running BAT files.

Because CMD.EXE doesn't understand UNC paths it can't set the current directory and so it defaults to the Windows directory. Since your BAT file is not in the Windows directory CMD.EXE can't find it to process it and the call to EXEC fails.

The same fate may befall any application that uses the output of GetModuleFileName, GetCurrentDirectory, or attempts to parse the command line without accounting for the possible use of UNC paths. I created a simple application display it's own command line and the current directory to demonstrate the difference between Flash CS3 and previous versions.

When called from a Flash 8 projector:


When called from a Flash CS3 projector:


This doesn't mean that all applications will automatically fail, but if they depend on the current directory and they don't accept UNC paths, then they may not work as expected.

The reason you can still run BAT files on Windows 98 and ME is because they use a different command processor (command.com) and Flash CS3 doesn't generate UNC path on these systems. So for these older Windows systems you can still EXEC a BAT file.

Unless Adobe reverts to passing DOS paths instead of UNC path there is only one feasible solution to using BAT files with Flash. Instead of launching the BAT file directly we need a helper application that can launch the BAT files for us instead of depending on the command processor. Luckily a FREE solution to this problem already exists.

A few years ago I created a utility called proxy to run BAT files and hide the ugly DOS box that appears. It makes your projectors look more professional and gets around the problem Flash CS3 has with BAT files. The proxy utility now has a permanent home on this blog.

Conquering FSCommand EXEC Part 1 : Proxy explains how to use proxy and contains a link to download proxy.exe.

Comments



your the best!! thank you so much
Posted by marcos on 11 Sep 2007 at 2:57pm
at last after many hours of browsing :)
Posted by polyetilen on 30 Oct 2007 at 6:48pm
Thanks Dude....
Posted by Priyanath on 2 Nov 2007 at 3:05am
Last night you save my life

Thank yoouuuuuu a lot !!!

Gracias campeón.
Posted by Sergio on 30 Nov 2007 at 7:59am
THANK YOU!!!
THANK YOU!!!
THANK YOU!!!

I was going crasy...


Posted by Alejandro on 3 Dec 2007 at 8:04pm
You're the best.
No comment.
Just applause.

Thanx a lot, you save my life.

ST3M
Posted by ST3M on 7 Dec 2007 at 1:39pm
Thank you, not only for taking the time to solve the problem, but also to explain what has happened on Adobe's end. I've used proxy.exe prior to CS3 for convenience issues. Now I'm so glad that it has a permanenet home here for solving such a serious issue.

Cheers,

-MT
Posted by MTippin on 14 Jan 2008 at 10:21pm
u've saved me
Posted by naveed on 11 Feb 2008 at 12:59pm
Thank you, very useful information.
Posted by cosmoz on 15 Feb 2008 at 5:46am
Yes, you are completely awesome!!

I've been using the older version and this update was super easy to implement!

Thank you for sharing and educating me!
Posted by Giovanna Ghio on 23 Apr 2008 at 5:02pm
great thank you from Italy - Rimini
By Sara
Posted by Sara on 30 May 2008 at 5:58am
Thanks. That sorted my PC .exe.

This may be the same problem that was causing my projector not to work on Macs. ie it could not find the applescript app to run. The solution that I found was to save the fla from CS3 to Flash 8 and then re-create the projector. Then it all works fine.
Posted by andy on 15 Jun 2008 at 2:04pm
CS3 broke fscommand for Macs as well. I'm not sure exactly how, but I suspect that it was something similar. Going back to Flash 8 would definitely get around the problem if that's an option for you.
Posted by Tim on 16 Jun 2008 at 12:56pm
OH MY GOD! THANK YOU!!!!!!!!!!!
Posted by Robbie Lockie on 12 Aug 2008 at 5:12pm
you'r genius!!!

you'r god!!

thank you very very very mouch!!

ps. i'm korean^^;;
Posted by south.korean on 17 Aug 2008 at 9:18pm
Man,

You have just saved my life !!!!


Best Regards
Posted by Marcelo on 9 Sep 2008 at 2:16pm
Hey super!!!

I was already giving up ...

'cause SwishMAX forbids executing exes already when exporting in Flash 7
Posted by genesis-upanishad on 23 Sep 2008 at 5:00pm
Muchas Gracias!!!!
Posted by Maco on 28 Sep 2008 at 3:39am
Muito BOM !
tanx !!!!!
Posted by Helio Bernardo on 30 Sep 2008 at 12:49pm
Just great, great! GREAT!!!
Posted by Shark on 27 Oct 2008 at 1:25pm
Thank you SO MUCH my friend for your help!!!!!

If I had the chance, I would french kiss you!!!

THANX AGAIN!!!
Posted by Martin on 28 Oct 2008 at 4:17pm
Your thanks is DEFINITELY enough :)
Posted by Tim on 28 Oct 2008 at 5:06pm
Hi! I've tried this and it worked, but I'm having another problem. My Flash projector is in fullscreen "(fscommand("fullscreen","true");" and when I click the button to open the pdf using this method, the flash projector resizes to Flash Stage measure (1024x768).
How can I avoid to resize the projector fullscreen?
Thank you!
Posted by MGaspar on 30 Oct 2008 at 11:07am
That's another bug I covered in Problem with Fullscreen Flash Projectors.
Posted by Tim on 30 Oct 2008 at 11:20am
You are my idol! I've heard legendary things about you, but I've been reading your blog all afternoon. The legends are true. Thanks Tim! You're a huge asset to all of us.
Posted by Andrew on 4 Feb 2009 at 3:34pm
Buddy u rock!!!!
You solved a big problem of mine....u are great....
:D
Posted by Umar on 23 Feb 2009 at 12:38am
Thank you!
Brainless developers from Adobe must erect a monument in your honour!
Posted by oleg on 26 Feb 2009 at 11:39am
Really nice little executable.

Came along it since I needed to open files in AS3, and had been struggling for a few hours. I will add an article to it on my site and link to this article.

Thanks alot.
Posted by Diego Veras on 30 Mar 2009 at 8:00pm
Great help,
Thanks
Posted by Rui Couto on 5 May 2009 at 4:39am
Thank's very very much.
Posted by oro on 13 May 2009 at 9:32am
you are all these comments and a bag of chips

with the dip
Posted by mandrozi on 21 May 2009 at 7:15am
Thanks for the help! Very nice work.
Posted by Brendan on 31 May 2009 at 11:28am
Shalom from Israel,
thank you so much..
i spent days trying to solve the UNC path problem. your clear explanation, code and example solved it completely.
thank you.
Ido
Posted by ido on 3 Jul 2009 at 12:01pm
thank you so much for helping me. A take an urgent project to finish and i was starting going crazy.
Posted by cleudson cunha on 11 Sep 2009 at 10:23am
Muchas gracias!
What do I do in case that I need to have more than one button? This is what I am doing but it is not working: copy the button and change the fscommand("exec", "a.exe")
and the other button fscommand("exec, "b.exe")
Posted by Aquiles on 2 Nov 2009 at 1:34pm
You also need to make sure you have all the external files: a.exe, a.bat, b.exe and b.bat and the files you want to launch from the BAT files in the fscommand folder.
Posted by Tim on 31 Dec 1969 at 7:00pm
Thank you!!!
Posted by vedran on 27 Jan 2010 at 4:57pm
I'm creating the CD Interface in Flash. all the animations are Done but i'm stuck in directly start the exe file. Thank You for your valuable suggestions about fscommand

THANK YOU FOR HELP, VERY NICE WORK
Posted by Vikram Pawar on 10 Feb 2010 at 2:35am
i want to kiss your feet!

thank you! thank you! thank you!
Posted by mala on 22 Mar 2010 at 5:55am
Thanks

This is gonna be really helpfull for my project

Thanks!!
Posted by Michael on 21 May 2010 at 1:58pm
This looks like the solution....but...

I'm using proxy with CS3 and Player 9 on Mac OSX but generating the exe to run on Windows. The exec just doesn't launch any of the PDF or Word documents I want to showcase. Also, when I publish my projector as Flash8 it still comes up as FlashPlay9 Projector. Am I missing something here?

I also looked at the example shown for proxy and the projector is a Player 6 format.

Any idea on what I'm doing wrong? I sense it's because my projector still says Player9....

Best
Posted by Mike on 20 Jul 2010 at 4:44am
If you're using CS3 then Flash Player 9 is what all your EXE files are going to say because that's the version of the standalone player that's included with CS3. You can publish your SWF in Flash 8 format but the EXE that plays it is still going to be the Flash 9 player. To figure out why the EXEC commands aren't doing what you want I'll need to see what you're doing and where you're putting your files. It might be easier to discuss that in our forums.
Posted by Tim on 20 Jul 2010 at 5:59am
Hey...thanks a ton mate...You're a real life saver!
I can't believe Adobe has left such a big loop hole.
Posted by Kaboosh on 3 Sep 2010 at 3:26pm
Thank you very much, I was killing my using the "old method". God bless you.
Posted by Armando on 8 Sep 2010 at 12:38pm
when I publish my projector as Flash8 it still comes up as FlashPlay9 Projector
Posted by uggs uk on 25 Oct 2010 at 1:37am
When you set the Flash version on the publish settings, what you're setting is the SWF format, not the EXE that will be used. The EXE that will be used is determined by the version of Flash that you're using. You need to publish your movie as a SWF then open it (manually) in the Flash 8 standalone player and create the EXE file using the File menu. You can read how to do that in another blog post I wrote about Problem with Fullscreen Flash.
Posted by Tim on 25 Oct 2010 at 2:26am
Thanks!
Posted by Denis on 14 Jan 2011 at 8:21am
i could do it in BUT ONLY WORK IN PC NOT IN MAC HEEEEEEEEEEEEEEEEEELP SOS
Posted by Mariella on 21 Mar 2011 at 4:08pm
The problem described in this post only affects Flash CS3 on Windows. If your Mac projector isn't working it's because of a different problem. The fscommand folder can't be beside the application, you have to put it inside the applicatio bundle. If you right click on YouApp.app on a Mac and select "Show Contents" you'll see a bunch of folders. You want to navigate down to Contents->MacOS and create a folder called fscommand. This is where yout need to put the application you're trying to EXEC.
Posted by Tim on 21 Mar 2011 at 4:40pm
One question: do you have to rename your folder fscommand?

In order for this to work for me, I HAD to rename it fscommand - but for some reason it does NOT work with any other folder name. Is there an explanation for this?
Posted by Eleanor Joel on 28 Apr 2011 at 11:17am
The folder must be called fscommand, it's part of the Flash security sandbox. The reason it has to be called "fscommand" is simple, Macromedia (now Adobe) said so. If you use a third party swf2exe tool like SWF Studio then you can avoid this issue completely.
Posted by Tim on 28 Apr 2011 at 12:58pm

Leave a Comment



Add a comment by filling out the form below. All comments will be reviewed before they appear.
You only need to provide a valid email address if you need/want a personal reply to a question.
Your email address will not be shown and you won't get spammed for using it.

name:

email:

website:

comment:




← Back
 

copyright © 2000-2011 Northcode Inc  ·  all rights reserved  ·  contact us  ·  report piracy  ·  privacy policy