15 Replies Latest reply on Sep 17, 2008 7:23 AM by Kasyan Servetsky

    Startup script launches itself 3 times (without no loop inside) !!!

    Loic.Aigon Adobe Community Professional
      Hi I am facing a curious behavior.
      If I put a script in the startup script so the script is persistent throught the session, I notice that the script is executed 3 times.
      For example, If I put an alert, it appears three times. I click ok, it comes back, ok, it comes back, I click ok then the alert does not come back again.
      That's annoying.
      Is there anything to avoid that ?
      Thanks for helping.
      Regards,
      Loic
        • 1. Re: Startup script launches itself 3 times (without no loop inside) !!!
          try67 MVP & Adobe Community Professional
          Could you post the script here? Do you have any other startup scripts installed?
          • 2. Re: Startup script launches itself 3 times (without no loop inside) !!!
            Level 1
            Hi Loic,

            Where, exactly, are you putting the startup script?

            Thanks,

            Ole
            • 3. Re: Startup script launches itself 3 times (without no loop inside) !!!
              Loic.Aigon Adobe Community Professional
              Hi all,
              Here is the script :

              Olav, I put the script in this folder on my Windows Xp at the office.
              C:\Program Files\Fichiers communs\Adobe\Startup Scripts CS3\Adobe InDesign\
              At home I have a Mac and tried to place the script in the startup scripts folder located in the Indesign main folder's subfolders (Export as Xhtml...).
              On the mac, I am not prompted but the script only work a few then do nothing more.

              #targetengine "session"
              logfiles();
              function logfiles()
              {
              var myApplicationEventListener = app.eventListeners.add("afterOpen",myEventInfo, false);
              }
              function myEventInfo(myevent)
              {
              var apppath = app.filePath;
              var doc = app.documents[0];
              //myevent.parent;
              //app.documents[-1];
              //app.open(File(myevent.parent.fullName));
              //Try all these options without any changes

              var filename = doc.name;
              var filepath = doc.fullName;
              var mydate = new Date;
              var myday= mydate.getDate();
              var mymonthlst = ["Janvier", "Fevrier", "Mars", "Avril", "Mai", "Juin", "Juillet", "Aout", "Septembre", "Octobre", "Novembre", "Decembre"]
              var mymonth = mymonthlst[mydate.getMonth()];
              var myyear = mydate.getFullYear();
              if(myday>15)
              {
              var monthsdaysnb = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
              var M = monthsdaysnb[0];
              var D ="16-"+M;
              }
              else
              {
              var D = "1-15";
              }
              var mylogsfolderpath=apppath+"/logsfolder";
              var logsfolder = new Folder(mylogsfolderpath)
              logsfolder.create();
              var mylogfile = logsfolder +"/fileslog_"+D+"_"+mymonth+"_"+myyear+".txt";
              if(File(mylogfile).exists==false)
              {
              var fileslog = new File(mylogfile);
              }
              else
              {
              var fileslog = File(mylogfile);
              }
              fileslog.open("r");
              var fileslogcontent = fileslog.read();
              if(fileslogcontent.indexOf(filename)==-1)
              {
              fileslog.open("e");
              fileslog.seek(0,2);
              fileslog.writeln (filename+"\r"+filepath);
              fileslog.close();
              }
              }

              Hope you can bring me the light :-)

              thx a lot in advance
              Loic
              • 4. Re: Startup script launches itself 3 times (without no loop inside) !!!
                Kasyan Servetsky Level 5
                Hi Loic ,

                I just put your script inside D:\Program Files\Adobe\Adobe InDesign CS3\Scripts\Startup Scripts folder on my PC and it seems to be working as expected.
                Or you can put it into User folder:
                C:\Documents and Settings\Kasyan\Application Data\Adobe\InDesign\Version 5.0\Scripts\Startup Scripts

                Folders like C:\Program Files\Common Files\Adobe\Startup Scripts CS3\Adobe InDesign are intended for scripts installed by applications, not by users.

                Kasyan
                • 5. Re: Startup script launches itself 3 times (without no loop inside) !!!
                  Loic.Aigon Adobe Community Professional
                  Hi Kasyan,
                  I tried what you offered me to do. It seems endless. I am really desperate now.
                  Now the script do not even work once and prompt immediatly for a error alert saying :

                  b javascript error #30476
                  b the action couldn't be achieved because the object doesn't exist anymore.
                  (sorry for the language, it's frenglish)

                  It seems that this alert comes twice cause when I click ok, it prompt me once again.

                  I am still looking on my side and start thinking I won't ver get the magic key :-(

                  Thanks you for having considered the question.
                  Loic
                  • 6. Re: Startup script launches itself 3 times (without no loop inside) !!!
                    Kasyan Servetsky Level 5
                    Loic,

                    I tested your script again, at my work this time, on Mac and PC, it works for me: creates logsfolder if it doesnt exist, creates file (e.g. fileslog_1-15_Septembre_2008.txt) and writes file name and path of opened file to it.
                    I was able to reproduce the exact error you have by putting the script into the wrong place (C:\Program Files\Common Files\Adobe\Startup Scripts CS3\Adobe InDesign).

                    Kasyan
                    • 7. Re: Startup script launches itself 3 times (without no loop inside) !!!
                      Loic.Aigon Adobe Community Professional
                      Ok Kasyan,
                      I must have offended a egyptian sanctuary and so I am damned for eternity :-(
                      Thanks for your help anyway. At least I know it runs, except at my place.
                      Maybe rebooting the PC will trash some temp files that annoy me.
                      I stop bugging you so.
                      Thanks once again.
                      Loic
                      • 8. Re: Startup script launches itself 3 times (without no loop inside) !!!
                        Level 1
                        Hi Loic,

                        Please double-check the ExtendScript startup script directory for copies of your script--if you put it there, as Kasyan says (thanks, Kasyan!), you'll get exactly the error you report. Again, this is the WRONG place to put the script (where "~" is your drive):

                        ~\Program Files\Common Files\Adobe\Startup Scripts CS3\Adobe InDesign

                        The RIGHT place to put the script is:

                        ~\Program Files\Adobe\Adobe InDesign CS3\Scripts\Startup Scripts

                        Thanks,

                        Ole
                        • 9. Re: Startup script launches itself 3 times (without no loop inside) !!!
                          Loic.Aigon Adobe Community Professional
                          Hi Kasyan & Olav,
                          Thanks a lot to you guys.

                          Kasyan, you ironically first make me feel depressed cause Icouldn't understand why I was like the only one that couldn't make it run properly. But in the same time, it was nice to know that the main part, the script, was working.

                          Olav, your last remark about ExtendScript startup script directory was a good hint. I digged on this way and finally reviewed the
                          Adobe InDesign CS3 Scripting Tutorial.pdf that precise the path :

                          i Mac OS: ~/Library/Preferences/Adobe InDesign/Version 5.0/Scripts

                          i Windows XP: ~\Documents and Settings\user_name\Application Data\Adobe\InDesign\Version 5.0\Scripts

                          i To run a specific script when InDesign starts, put the script inside a folder named Startup Scripts inside the Scripts folder (create this folder if it does not already exist).

                          So after placing my script there, it seems that the script on my mac at home runs well. I will check on my PC at the office but it shouldn't be a trouble any longer. I hope so.
                          I won't be at the office till Monday so I won't be able to give you a feedback for windows before but whatever happens I will keep you in touch.

                          Thanks you a lot. That was so frustrating. I was close to cry really.

                          Loic

                          PS: Olav, I think I was blinded by the fact that "Startup Scripts" folders already existed. I thought that it was the place to go. And there was my mistake.
                          • 10. Re: Startup script launches itself 3 times (without no loop inside) !!!
                            Loic.Aigon Adobe Community Professional
                            Hi Olav & Kasyan,
                            I have bad news.
                            Put the script here and in my office's windows XP, it still refuse to run properly bugging for javascript error 30476.

                            C:\Documents and Settings\Loic\Application Data\Adobe\InDesign\Version 5.0\Scripts\Startup Scripts\Raccourci vers write_files_log.jsx

                            FYI
                            Loic
                            • 11. Re: Startup script launches itself 3 times (without no loop inside) !!!
                              Level 1
                              Hi Loic,

                              So it's a difference between your home machine and your office machine. The first thing to suspect: permissions. Are you logged in as an Administrator on your work machine?

                              Thanks,

                              Ole
                              • 12. Re: Startup script launches itself 3 times (without no loop inside) !!!
                                Loic.Aigon Adobe Community Professional
                                Hi Olav,
                                I will have a look tomorrow at the office and let you know.
                                I have a lot of files disseminated on many servers, could you think it could be the source of the issue ?
                                Thanks for your patience and understanding
                                Loic
                                • 13. Re: Startup script launches itself 3 times (without no loop inside) !!!
                                  Loic.Aigon Adobe Community Professional
                                  Hi Olav,
                                  I checked this morning and noticed I am on a administrator machine with all priviledges.

                                  I don't know if it can help but :

                                  var mytxtfile = new File("/c/Program Files/Adobe/Adobe InDesign CS3/logsfolder/toto.txt");
                                  mytxtfile.open("e");
                                  mytxtfile.write("toto");

                                  through ESTK works fine. The file is created. So I guess I can operate in this folder without restrictions.

                                  Thanks for your care.

                                  Loic
                                  • 14. Re: Startup script launches itself 3 times (without no loop inside) !!!
                                    Loic.Aigon Adobe Community Professional
                                    Hi Olav, Kasyan,
                                    Just to close the book, it finally works on my office machine.
                                    I don't know what happened special but after many attempts to make it run, it finaly started.
                                    I have no explanation but I am glad to get it at end.
                                    Thanks for all your time and efforts to help me.
                                    Loic
                                    • 15. Re: Startup script launches itself 3 times (without no loop inside) !!!
                                      Kasyan Servetsky Level 5
                                      Loic,

                                      It makes me glad to hear that it works at last, although the mystery still remains unsolved.

                                      Kasyan