sketchucation logo sketchucation
    • Login
    ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info

    Translate My Documents

    Scheduled Pinned Locked Moved Developers' Forum
    18 Posts 5 Posters 1.2k Views 5 Watching
    Loading More Posts
    • 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.
    • J Offline
      Jim
      last edited by

      On the person's computer, ENV["USERPROFILE"] returns:

      "C:\Users\Jim"

      When the location is:

      Doctored Image

      What is Equipo? Is it "My Computer"?

      (I will now re-read the thread and see what I missed.)

      Hi

      1 Reply Last reply Reply Quote 0
      • J Offline
        Jim
        last edited by

        Just FYI, there is a User Shell Folder key because, from the article (2003)..

        @unknownuser said:

        the "Shell Folders" key exists solely to permit four programs written in 1994 to continue running on the RTM version of Windows 95.

        The gist of the article is do not rely on registry keys directly and use the system library to read the location of the special folder names. The article is aimed at Windows application developers, but it applies here because reading these registry keys isn't giving the desired result.

        HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders

        Which in my case looks like this:

        401.png

        But from my previous post, it would not return the desired path either. The real directory name is Usuarios, and not Users.

        (My Google skillz rulez!)

        Hi

        1 Reply Last reply Reply Quote 0
        • Chris FullmerC Offline
          Chris Fullmer
          last edited by

          Jim, did you do a full install in spanish? OR just change the language to spanish on your existing system?

          Lately you've been tan, suspicious for the winter.
          All my Plugins I've written

          1 Reply Last reply Reply Quote 0
          • J Offline
            Jim
            last edited by

            Neither, it's not my computer.

            Right now, I think the answer is in using Win32API, but need to learn to use it make the system call.

            The Dir::PERSONAL would probably work, but there are more than a few dependencies, and it complains about the Ruby Version being 1.8.0 (in SketchUp) instead of my installed 1.8.6, so I can't get it to work easily.

            Update: I think I found a single-file (or 2-file) solution. Test pending...

            Hi

            1 Reply Last reply Reply Quote 0
            • Dan RathbunD Offline
              Dan Rathbun
              last edited by

              @tig said:

              ... or if it's always on a PC then hack the registry use 'cmd' etc:
              HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders String value: Personal
              which will return the path to the 'My Documents' folder in any locale...

              YES, what TIG said! πŸ‘

              Because I "think" XP and earlier used "My Documents",
              and Vista (v6) and later (Win 7) uses "Documents" (more like UNIX, Linux and OSX.)
              I'm not sure when the change occurs for Windows Server versions.

              (a) You can call Reg.exe either thru a back-quoted string or IO.popen

              (b) Use the standard Ruby library for Windows Registry
              ENV['RUBYLIB'+'/lib/win32/registry.rb']
              which relies upon Win32API.so

              
              def get_docs_dir
                @dir=''
              if RUBY_PLATFORM.include?('mswin')
                reglib = ENV['RUBYLIB']+'/lib/win32/registry.rb'
                if test( ?e, reglib )
                  require reglib # require uses absolute paths before iterating $;
                  key = 'Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders'
                  Win32;;Registry;;HKEY_CURRENT_USER.open( key ) do |reg|
                    @dir = reg['Personal']                               
                  end # let block end normally so key gets automatically closed
                end
              else
                raise( NotImplementedError, 'Not a Windows Platform' )
              end
                return @dir
              end # def
              
              

              EDIT: changed string append to concat in line 4

              I'm not here much anymore.

              1 Reply Last reply Reply Quote 0
              • thomthomT Offline
                thomthom
                last edited by

                require 'win32dir.rb' true p Dir::DESKTOP "C:\\Users\\Thomas\\Desktop" nil p Dir::PERSONAL "C:\\Users\\Thomas\\Documents" nil p Dir::APPDATA "C:\\Users\\Thomas\\AppData\\Roaming" nil p Dir::LOCAL_APPDATA "C:\\Users\\Thomas\\AppData\\Local" nil

                Thomas Thomassen β€” SketchUp Monkey & Coding addict
                List of my plugins and link to the CookieWare fund

                1 Reply Last reply Reply Quote 0
                • Dan RathbunD Offline
                  Dan Rathbun
                  last edited by

                  @thomthom said:

                  [ruby]require 'win32dir.rb'

                  Where do you get 'win32dir.rb' ??
                  Looks like a Windows extension to the Dir base class.

                  I'm not here much anymore.

                  1 Reply Last reply Reply Quote 0
                  • J Offline
                    Jim
                    last edited by

                    I'm almost sure it is from win32utils, but it must be an earlier version because the current version of the file has changed considerably.

                    The current version has a list of dependencies on other libraries, while this version only requires win32api.so

                    I've attached the version here that relies only on win32api.so

                    I'd be interested if it returns the localized names of Dir::PERSONAL, et al.


                    dir.rb

                    Hi

                    1 Reply Last reply Reply Quote 0
                    • thomthomT Offline
                      thomthom
                      last edited by

                      I think that on Vista/W7 they changed the windows folder to always be in English, but with an aliasing scheme for presenting them localized to the user in some cases. (I'm a bit confused on how it really is set up.)

                      But on XP the folder names for sure is localised. I can try later today on my old laptop with Norwegian XP.

                      Thomas Thomassen β€” SketchUp Monkey & Coding addict
                      List of my plugins and link to the CookieWare fund

                      1 Reply Last reply Reply Quote 0
                      • J Offline
                        Jim
                        last edited by

                        Hopefully, this file will work. It uses the system call ShGetFolderPath or ShGetSpecialFolerPath to retrieve the folder, so maybe the paths will be localized.

                        @thomthom said:

                        But on XP the folder names for sure is localised. I can try later today on my old laptop with Norwegian XP.

                        I'd be interested to see if it works.

                        Hi

                        1 Reply Last reply Reply Quote 0
                        • 1 / 1
                        • First post
                          Last post
                        Buy SketchPlus
                        Buy SUbD
                        Buy WrapR
                        Buy eBook
                        Buy Modelur
                        Buy Vertex Tools
                        Buy SketchCuisine
                        Buy FormFonts

                        Advertisement