Announcement

Collapse
No announcement yet.

Searching for Path

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Searching for Path

    Hi,

    This is my first experience creating an install program and I need help. I've bought the clicknlearn insight training CDs and found them to provide a wealth of knowledge which has helped me tremendously in getting started, but I have a particular problem that I need help with. I need to install a document template (.dot file) in the user's Startup directory for Word. So I need to know how to find the path on the user's machine to \Word\STARTUP, i.e.:

    User's Drive\Path??\Word\STARTUP

    The problem is I can't search for a file, because there may not be anything in this directory. Once I find out what the path is to go to \Word\STARTUP I then want to install a document template into the STARTUP directory.

    Could anyone out there help me? Any help would be greatly appreciated.

    Thanks,

    Bob

  • #2
    Re: Searching for Path

    Instead of searching for a file in that particular folder, search for Winword.exe. The Startup folder should be in the same folder as Winword.exe

    Comment


    • #3
      Re: Searching for Path

      Thanks Worm. The problem I have with that is this. On my system (for example), Winword.exe is located at:

      c:\Program Files\Microsoft Office\Office

      The location where I would need to copy my document template to my computer would be:

      c:\Documents and Settings\Owner\Application Data\Microsoft\Word\STARTUP

      Of course this would change depending on the user's OS and where they installed Word initially. To get the path to the Word\Startup folder in VBA, you would use MsgBox Options.DefaultFilePath(wdStartupPath), but I don't have a clue as to how I could go about getting it using Setup Factory.

      Again, any help would be greatly appreciated. I'm a real novice at this.

      Thanks!

      Bob

      Comment


      • #4
        Re: Searching for Path

        As an update, I figured out that I can do a Search for File to find the path of a standard file used in Word, i.e.: Normal.dot. From this result I can use the Parse Path (action) to get the path. What I need to do, however, is to remove the last folder in the returned path which would be called "Templates" and then add \Word\STARTUP\ to the result to define where I want my file to be installed. So, here's my question: How can I remove the last folder in the path?

        Thanks for the help.

        Bob

        Comment


        • #5
          Re: Searching for Path

          One method you could use is the following:

          I assume you will have the path in a variable initially. Let's call it %Path%.
          1) The first step would be to count how many characters are in that string. You can do this using the "Length of String" action.

          2) The next step involves finding the length of the string you want to keep from the path. From what you have said, you already know the length of the last folder, which is "Templates", which is 9 characters. So you would then use an "Assign Value" action with the "Evaluate value as expression" option checked to subtract 9 from the total length of the string. The result is the number of characters from the left hand side of the string that you want to keep.

          3) Next you could use the "Left String" action to copy the number of characters from step 2 to form a new string.

          4) Now that you have the new string, you will need to concatenate the new string "Word\Startup\" with the string you received from step three. To do this you would use the "Assign Value" action with the "Evaluate value as expression" checkbox checked to perform string addition, for example:

          %String1% + %String2%

          You should then have the string you wish to have.

          Hope that helps.

          Comment


          • #6
            Re: Searching for Path

            Hi Darryl,

            Thank you so much for your assistance. I haven't tried this out yet because of lack of time, but hopefully I'll start working through your recommended method in detail by sometime tomorrow. I'm not sure if I understand everything, but with the clicknlearn tutor, I think I should be able to get through it. Part of the big learning curve I guess.

            Again, thanks a lot for your assistance. The content of this forum has been invaluable.

            Bob

            Comment


            • #7
              Re: Searching for Path

              No problem Bob. If you need a little more clarification on any of the parts, feel free to post back once you fool around with it a bit.

              Comment


              • #8
                Re: Searching for Path

                Hi Darryl,

                I took your advise and fooled around with the features a bit while implementing the method you described, and as a result, I put the following together which worked, but the program took almost 4 minutes to find the Normal.dot file before the setup program started:

                Assign Value (%PathExt% = Word\STARTUP)
                Search for File (%PathToUsersNormalFile% = location of Normal.dot)
                IF (%PathToUsersNormalFile% <> False)
                Parse Path (%RoughPath% = Drive and folder part of %PathToUsersNormalFile%)
                Length of String (%LengthStringResult% = length of string "%RoughPath%")
                Assign Value (%NetLengthOfString% = %LengthStringResult% - 9
                Left String (%LeftStringResult% = left-most %NetLengthOfString% characters of "%RoughPath%")
                Assign Value (%ModulePath% = %LeftStringResult% + %PathExt%)
                END IF

                Because of this, I decided that perhaps I would be better off using one of the built-in variables, namely %MyDocumentsDir%. With this, I ended up putting together the following which seems to work almost without any delay at the beginning and seems to get the same results:

                Assign Value (%PathExt% = Application Data\Microsoft\Word\STARTUP)
                Length of String (%LengthStringResult% = length of string "%MyDocumentsDir%")
                Assign Value (%NetLengthOfString% = %LengthStringResult% - 12)
                Left String (%LeftStringResult% = left-most %NetLengthOfString% characters of "%MyDocumentsDir%")
                Assign Value (%ModulePath% = %LeftStringResult% + %PathExt%)

                The only problem I'm having with all of this is when I uninstall. Everything works great except that when my uninstall removes the file from the STARTUP folder, it also removes the STARTUP folder as well. This happens regardless of whether I run the first set of actions or the second set. So here's my question: How can I prevent the STARTUP folder from being deleted during uninstall?

                Your help on this would be greatly appreciated. Thanks again!

                Bob

                Comment


                • #9
                  Re: Searching for Path

                  Hi Darryl,

                  OK, I figured out what was going on. If the STARTUP folder only contains the file I installed originally, when uninstall removes it, it removes the folder as well. However, if there is another file in the same folder, the folder remains. As for the missing folder, as soon as Word is opened, that same STARTUP folder is created again by Word.

                  So everything is working OK. Thanks for your time and patience. Learning a new software program can take some time and effort and it's good that a forum like this is available. Thanks again.

                  Bob

                  Comment


                  • #10
                    Re: Searching for Path

                    I'm happy to hear you got things going. I just wanted to point one thing out to you that may help now or in the future. In the Search for File action there is the option "Search specific directories/drives". This can be a delimited string of paths to search. Sometimes it's nice to create an action that searches some common directories where you believe it will be. Then if that fails you could perform a wider search with another action. Just a suggestion.

                    What you may have to do in the case of the folder removal is install a dummy text file in the STARTUP folder and set its install attributes to "Never Remove" so it is skipped by the uninstall. If there is anything in that folder, it will not be removed by Setup Factory. You could then use a Delete Files action to remove the file.

                    Hope that helps.

                    Comment


                    • #11
                      Re: Searching for Path

                      Darn! You beat me to it!

                      Comment

                      Working...
                      X