How to change defaultLocation based on the OS

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • David R
    New Member
    • Dec 2008
    • 14

    How to change defaultLocation based on the OS

    I have a windows application using .net 1.1

    In the setup project I set the DefaultLocation to
    [ProgramFileFold er][Manufacturer]ABC

    Is there a way to change this defaultLocation based on the OS.
    I'd like to leave this location when installing on Windows XP but change the location to another path when installing on Windows Vista.

    Can I use an If-statement to determine the OS and then set the DefaultLocation ?
    Last edited by Frinavale; Dec 30 '08, 07:54 PM. Reason: Moved to C# forum
  • SammyB
    Recognized Expert Contributor
    • Mar 2007
    • 807

    #2
    Originally posted by David R
    I have a windows application using .net 1.1

    In the setup project I set the DefaultLocation to
    [ProgramFileFold er][Manufacturer]ABC

    Is there a way to change this defaultLocation based on the OS.
    I'd like to leave this location when installing on Windows XP but change the location to another path when installing on Windows Vista.

    Can I use an If-statement to determine the OS and then set the DefaultLocation ?
    Yes, just look at Environment.OSV ersion and set Environment.Cur rentDirectory

    HTH --Sam

    Comment

    • David R
      New Member
      • Dec 2008
      • 14

      #3
      I guess I don't know where to do this

      Comment

      • SammyB
        Recognized Expert Contributor
        • Mar 2007
        • 807

        #4
        What language are you using (C# or VB)? What sort of app (Windows or ASP)? In any case, you'll want to put it first thing: probably in the form load event, assuming that you have a form.

        Comment

        • David R
          New Member
          • Dec 2008
          • 14

          #5
          Its a Windows app, C#. .net 1.1
          No, I do not have a form load event

          Comment

          • SammyB
            Recognized Expert Contributor
            • Mar 2007
            • 807

            #6
            >No, I do not have a form load event
            Does your app have a form? If so, just double-click on the form in the designer & you will have the outline for the load event. If not, what code gets executed first? can't you put it there?

            Comment

            • David R
              New Member
              • Dec 2008
              • 14

              #7
              I guess I'm not understanding.
              I have 2 projects in my solution. One is the application itself, the second is the setup project.
              In the setup project I setup the application folders to be created during the installation.
              A property of the Application Folder is "DefaultLocatio n" where I have it set to "[ProgramFilesFol er][Manufacturer]\ABC"

              How do I change this location based on the OS during setup?

              Comment

              • sglidden
                New Member
                • Mar 2010
                • 1

                #8
                David, Did you ever figure out how to do this?
                I need to do this as well...change the DefaultLocation during installation based on OS.

                Comment

                • MrMancunian
                  Recognized Expert Contributor
                  • Jul 2008
                  • 569

                  #9
                  Add an Installer Class to your project (not in the setup). In this class, you override the Sub Install. In this class, you change the default installation location. Build your project! Now, in your Setup project, you add a Custom Action to the Install and choose the Primary output of the other project. That should do the trick.

                  Steven

                  Comment

                  Working...