6 Replies Latest reply on Mar 17, 2011 6:25 AM by Mayhem SWE

    Self-installing script?

    Mayhem SWE Level 2

      Hello all,

      I am currently working on an InDesign script (CS3 for now, my employer has been promising CS5 for months but never delivers) which a client presumably will be deploying across many different offices with varying computer skills. In order to make this process as painless as possible, I'd like for the script to be self-installing; Double-click the script in Finder/Explorer and (after prompting the user for confirmation) it'll move itself to the Scripts Panel folder and supporting files to suitable locations.

       

      Now the problem is I cannot seem to figure out how to get the file path to a script which was executed by opening directly from Finder. The usual methods do not work, app.activeScript fails for obvious reasons while try{}catch(error){error.fileName} and $.fileName both returns "indesign-5.0-en_us:bridgetalk" rather than the original JSX file path. Anyone know of a solution?

       

      Here is the simplest of test cases. Save as a JSX file and see how the results differ depending on whether you opened the file from the Finder (or Windows Explorer) or ran it in ESTK or from the InDesign scripts panel.

       

      #target indesign
      try {
            alert("app.activeScript\n" + app.activeScript + "\n\n$.fileName\n" + $.fileName);
      } catch (error) {
            alert("error.fileName\n" + error.fileName + "\n\n$.fileName\n" + $.fileName);
      }

       

      The best I can come up with is a workaround; Embed support files into the script as binary strings (which I'd like to avoid if possible) and access the script itself through error.source which is then written out to a File object. Or simply reveal the correct location through app.scriptPreferences.scriptsFolder.execute() and then prompt the user to manually move the files there, but that kind of defeats the purpose of automation!