5 Replies Latest reply on Dec 4, 2013 8:44 AM by Jump_Over

    Getting the computers username in to a text box in indesign

    thomcook

      Hi

       

      I'm totally new to scripting but at my firm they want to have a text box on their InDesign documents that will show the username of the computer. The idea is that this would be tagged a little like you do in data merge so the box would be '<<USERNAME>>' and this would automatically change to the name of the computer account using it. We did have aguy working on this but he left. I found a script on his computer that had the file 'username.jsx' in his InDesign scripts. When you open it simply has the line '$.getenv('USER')' in it but I have no idea how to make this work.

       

      We are all working on macs.

       

      Any help would be appreciated.

       

      Thanks

      Thom

        • 1. Re: Getting the computers username in to a text box in indesign
          Gonterman1201 Level 1

          Yeah that should get the user. You could also do something like this.

           

          if (File(["/Applications/OPCS"]).exists){

                  var myFile2 = File(["/Applications/OPCS"]);

                  myFile2.open("r",undefined,undefined);

                  var computerOperator = myFile2.readln();

                  myFile2.close();

              }

           

          Then you will have to apply computerOperator to a text box.

          • 2. Re: Getting the computers username in to a text box in indesign
            thomcook Level 1

            Hi Gonterman1201

             

            Thanks for your reply. I couldn't get your If statment to retun a value but I have managed to get the $.getenv('USER') statment working and returing the home folder name. Which has now presented a new problem. Though everyones account on their mac is now set to their name the orgional accounts for all our macs was set to 'macuser' and this is the name of their home folders. I have researched changing the home folder name but this means going through everyones computer and exporting their user accounts to a new account, something I would dearly like to avoid. Is there a a different comand i can use that will return the Account name other than the deep compter name? I thought it maybe something like $.getenv('ACCOUNT_ID') or something as simple as that.

             

            Thanks once again for you reply.

             

            Thom

            • 3. Re: Getting the computers username in to a text box in indesign
              Gonterman1201 Level 1

              This $.getenv('USER') should give you the user name. It would depend on what user they are using.

              • 4. Re: Getting the computers username in to a text box in indesign
                thomcook Level 1

                When our IT departemnt set up the macs in our office they just named them all macuser. The users have just modified the account names to theirs but the host folder is still called macuser and that's the string being returned with $.getenv('USER'). If they creat a new account and set it up with their name from the begining then there's no problem and the command works fine. Problem is everyone setting up new accounts when they've got their workspaces set up just how they want them or having to export each account to a new user on each machine. I didn't know if there was a different variable other than USER that would return the login name the accounts set to?

                 

                Thanks

                Thom

                • 5. Re: Getting the computers username in to a text box in indesign
                  Jump_Over Level 5

                  Hi,

                   

                  You could check other variables like:

                  • $.getenv("USERPROFILE")     //last part of a path
                  • $.getenv("HOMEPATH")      //last part of a path
                  • $.getenv("COMPUTERNAME")

                   

                  Notice it works on Windows. Those names can differ on Mac, i.e. "USERNAME" on Windows is "USER" on Mac.

                   

                  Jarek