Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. How do i know in which drive windows is installed

How do i know in which drive windows is installed

Scheduled Pinned Locked Moved C#
question
7 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • I Offline
    I Offline
    Iftekhar Naim
    wrote on last edited by
    #1

    i need to invoke a windows method. For this i call an exe file from windows\system32 directory. But i need to know in which drive winodws is installed. I think it is not wise to hard-code my code -"c:\windows\system32". So can any one tell me how do i know this path from my program in run time? Thanks

    Chayan

    P P M 3 Replies Last reply
    0
    • I Iftekhar Naim

      i need to invoke a windows method. For this i call an exe file from windows\system32 directory. But i need to know in which drive winodws is installed. I think it is not wise to hard-code my code -"c:\windows\system32". So can any one tell me how do i know this path from my program in run time? Thanks

      Chayan

      P Offline
      P Offline
      PIEBALDconsult
      wrote on last edited by
      #2

      I use System.Environment.ExpandEnvironmentVariables to expand %windir% e.g. string MediaDir = System.Environment.ExpandEnvironmentVariables ( @"%windir%\Media\" ) ;

      C 1 Reply Last reply
      0
      • I Iftekhar Naim

        i need to invoke a windows method. For this i call an exe file from windows\system32 directory. But i need to know in which drive winodws is installed. I think it is not wise to hard-code my code -"c:\windows\system32". So can any one tell me how do i know this path from my program in run time? Thanks

        Chayan

        P Offline
        P Offline
        Paul Conrad
        wrote on last edited by
        #3

        Look for the Windir system variable in the environment variables... System.Environment.GetEnvironmentVariable("windir") will return the string where Windows is installed :)

        "The clue train passed his station without stopping." - John Simmons / outlaw programmer

        I 1 Reply Last reply
        0
        • P PIEBALDconsult

          I use System.Environment.ExpandEnvironmentVariables to expand %windir% e.g. string MediaDir = System.Environment.ExpandEnvironmentVariables ( @"%windir%\Media\" ) ;

          C Offline
          C Offline
          Chayan cse student
          wrote on last edited by
          #4

          Hey, Thanks a lot for such quick response. It's really great !!! Thanks mate..:-D

          Chayan

          1 Reply Last reply
          0
          • P Paul Conrad

            Look for the Windir system variable in the environment variables... System.Environment.GetEnvironmentVariable("windir") will return the string where Windows is installed :)

            "The clue train passed his station without stopping." - John Simmons / outlaw programmer

            I Offline
            I Offline
            Iftekhar Naim
            wrote on last edited by
            #5

            Thanks mate for your great help. I am really happy to find such a simple and cool solution:-D. Thanks a lot !!!!

            Chayan

            1 Reply Last reply
            0
            • I Iftekhar Naim

              i need to invoke a windows method. For this i call an exe file from windows\system32 directory. But i need to know in which drive winodws is installed. I think it is not wise to hard-code my code -"c:\windows\system32". So can any one tell me how do i know this path from my program in run time? Thanks

              Chayan

              M Offline
              M Offline
              Mike Dimmick
              wrote on last edited by
              #6

              A better solution is System.Environment.GetFolderPath( System.Environment.SpecialFolder.System ).

              Stability. What an interesting concept. -- Chris Maunder

              I 1 Reply Last reply
              0
              • M Mike Dimmick

                A better solution is System.Environment.GetFolderPath( System.Environment.SpecialFolder.System ).

                Stability. What an interesting concept. -- Chris Maunder

                I Offline
                I Offline
                Iftekhar Naim
                wrote on last edited by
                #7

                Thanks a lot....Now i know multiple solutions to my problem..:)

                Chayan

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups