4 Replies Latest reply: Aug 10, 2014 7:22 AM by 4everJang RSS

    Executing a program from a script

    4everJang Community Member

      Hi all,

       

      Is there a way to run a program (some exe, with optional commandline arguments) from within a script ?

       

      Thanks

       

      Jang

        • 1. Re: Executing a program from a script
          Wiedenmaier Community Member

          Hi Jang,

          You can use File.execute to run an external exe file.

          But you can't provide parameters.

          In such cases I always write a temporary batch file and call

          new File("foo.bat").execute()

           

          Hope this helps

          Markus

           


          • 2. Re: Executing a program from a script
            4everJang Community Member

            Hi Markus,

             

            Yes, that would work. It is kind of clumsy, having to write a batch file just because I want to pass a parameter to an existing program, but if there is no other way to do it, it will have to be done this way. I was looking for an existing client that might give me access to certain Windows functions, possibly using an ActiveXObject interface, but there seems to be no such thing in FM extendscript. There is an ActiveXObject in FrameScript, I think, and that does not seem to use a batch file to make it work.

             

            Ciao

             

            Jang

            • 3. Re: Executing a program from a script
              Wiedenmaier Community Member

              Hi Jang,

               

              perhaps ExternalObject could be a solution for that. ExternalObject allows ExtendScripts to call functions in C dlls.

              So an ExternalObject works as a connector to a world outside of ExtendScripts, with interfaces in both ways.

                  

              There is an example for ExternalObjects in Adobe\Adobe Utilities\ExtendScript Toolkit CS4\SDK\Samples\cpp.

               

              Don't know if this works or could be a solution for this and I don’t know if my thoughts are in the right direction.

              I hope this information is useful nevertheless.

               

              If there is a way, which is easier or if somebody has got experiences with ExternalObjects please let me know.

              • 4. Re: Executing a program from a script
                4everJang Community Member

                Hi Markus,

                 

                Good idea, but in this case there is no DLL that performs the same functions as an EXE which does exist. I guess I will have to go via the batch file approach here. Thanks anyway. I will keep that option in mind for possible other applications.

                 

                Jang