Announcement

Collapse
No announcement yet.

How to open a directory with a windows system variable in the path?

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

  • How to open a directory with a windows system variable in the path?

    Hi m8s,

    Does anyone know in AMS how to open a directory with a windows system variable in the path?

    Like this:

    %HOMEPATH%\AppData\

    By default the %HOMEPATH% points to C:\Users\[user name]\
    in Win7.

    Many thanks!

  • #2
    %HOMEPATH% is an environment variable, and you can retrieve the contents of environment variables with os.getenv(), like in this sample:

    Code:
    local sPath = os.getenv("HOMEDRIVE") .. os.getenv("HOMEPATH") .. "\\AppData";
    Dialog.Message("Info", sPath);
    Ulrich

    Comment


    • #3
      thanks urich

      as we know
      we can open folders with the file.open command
      this code will work
      PHP Code:
      File.Open("c:\\"""SW_SHOWNORMAL); 
      why this one not work??
      PHP Code:
      local sPath os.getenv("HOMEDRIVE") .. os.getenv("HOMEPATH") .. "\\AppData";
      File.Open(sPath""SW_SHOWNORMAL); 

      Comment


      • #4
        File.Open() is for "opening" files or documents, not folders. If you want to show the contents of a folder, you should use File.ExploreFolder() instead, right?

        Ulrich

        Comment


        • #5
          yes urich

          but also
          PHP Code:
          local sPath os.getenv("HOMEDRIVE") .. os.getenv("HOMEPATH") .. "\\AppData";
          File.ExploreFolder(sPath
          do not show the content of the folder sPath

          remark
          i think that the command (file.open) opens the folder in the shell command "open"
          and the command (File.ExploreFolder) opens the folders in the shell command "explore"

          thanks

          Comment


          • #6
            also
            PHP Code:
            sPath Shell.GetFolder(SHF_APPLICATIONDATA);
            File.ExploreFolder(sPath
            works for me
            my os is win xp

            Comment


            • #7
              Originally posted by startup View Post
              my os is win xp
              On Windows XP you most probably won't find a sub folder named "AppData" in the user profile. That was not what was asked in the original question - the question was how to use an environment variable.

              Ulrich

              Comment


              • #8
                that is clear
                thanks for information Ulrich :yes

                Comment

                Working...
                X