Author Topic: How do I find the location of MyDocuments folder?  (Read 11881 times)

0 Members and 1 Guest are viewing this topic.

Krushert

  • Seagull
  • Posts: 13679
  • FREE BEER Tomorrow!!
How do I find the location of MyDocuments folder?
« on: April 19, 2011, 03:22:38 PM »
Using lisp, what do I use to find the location of MyDocuments folder?

FindFile will not work here  because the users MyDocuments folders resides between the parallel universe of the server and client machine.  I am being a wise flower and it long story as to why I want Autocad to find and it and not me hard coding the path into my code.  One reason is that I want to see if really knows where the folder is and not it following my path blindly.

The path as seen in the options dialog is
Code: [Select]
\\cws-server\users\ted krush\my documents\
I + XI = X is true ...  ... if you change your perspective.

I no longer CAD or Model, I just hang out here picking up the empties beer cans

alanjt

  • Needs a day job
  • Posts: 5352
  • Standby for witty remark...
Re: How do I find the location of MyDocuments folder?
« Reply #1 on: April 19, 2011, 03:25:57 PM »
Code: [Select]
(getvar 'MYDOCUMENTSPREFIX)
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

Krushert

  • Seagull
  • Posts: 13679
  • FREE BEER Tomorrow!!
Re: How do I find the location of MyDocuments folder?
« Reply #2 on: April 19, 2011, 03:33:03 PM »
Duhh!  "prefix"  I never thought of searching by prefix!   Thanks.
I + XI = X is true ...  ... if you change your perspective.

I no longer CAD or Model, I just hang out here picking up the empties beer cans

alanjt

  • Needs a day job
  • Posts: 5352
  • Standby for witty remark...
Re: How do I find the location of MyDocuments folder?
« Reply #3 on: April 19, 2011, 03:33:58 PM »
Duhh!  "prefix"  I never thought of searching by prefix!   Thanks.
I opened SYSVDLG and typed in *doc*. :-D
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

ronjonp

  • Needs a day job
  • Posts: 7529
Re: How do I find the location of MyDocuments folder?
« Reply #4 on: April 19, 2011, 03:52:08 PM »
Doesn't answer you question but here's a peek to the "special" folders:

Code: [Select]
(defun c:test (/ n out sa sp)
  (and (setq sa (vlax-create-object "WScript.Shell"))
       (setq sp (vlax-get sa 'specialfolders))
       (setq n -1)
       (repeat (vlax-get sp 'length) (setq out (cons (vla-item sp (setq n (1+ n))) out)))
       (alert (vl-prin1-to-string out))
  )
)

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

alanjt

  • Needs a day job
  • Posts: 5352
  • Standby for witty remark...
Re: How do I find the location of MyDocuments folder?
« Reply #5 on: April 19, 2011, 03:58:41 PM »
Very nice, Ron.

also...
Code: [Select]
Command: (findfile ".")
"C:\\Users\\athompson\\Documents"
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

ronjonp

  • Needs a day job
  • Posts: 7529
Re: How do I find the location of MyDocuments folder?
« Reply #6 on: April 19, 2011, 04:34:50 PM »
Very nice, Ron.

also...
Code: [Select]
Command: (findfile ".")
"C:\\Users\\athompson\\Documents"

:)  What is (findfile ".") pointing to?
Mine prints "C:\\Program Files\\Aqua Engineering, Inc\\WatermarkID 2009"

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

alanjt

  • Needs a day job
  • Posts: 5352
  • Standby for witty remark...
Re: How do I find the location of MyDocuments folder?
« Reply #7 on: April 19, 2011, 04:36:43 PM »
Very nice, Ron.

also...
Code: [Select]
Command: (findfile ".")
"C:\\Users\\athompson\\Documents"

:)  What is (findfile ".") pointing to?
Mine prints "C:\\Program Files\\Aqua Engineering, Inc\\WatermarkID 2009"
Sorry, I meant type out the question of what it returns for you.  :ugly:
I stumbled across that the other day and was quite puzzled by it - works with ".." also.
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

Jeff_M

  • King Gator
  • Posts: 4096
  • C3D user & customizer
Re: How do I find the location of MyDocuments folder?
« Reply #8 on: April 19, 2011, 04:42:32 PM »
I believe this returns the "Start in" folder specified in the shortcut used to start acad.

alanjt

  • Needs a day job
  • Posts: 5352
  • Standby for witty remark...
Re: How do I find the location of MyDocuments folder?
« Reply #9 on: April 19, 2011, 04:47:02 PM »
I believe this returns the "Start in" folder specified in the shortcut used to start acad.
I'm using pinned shortcuts in Win7, so that's probably why I'm receiving my documents folder. Interesting.
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

ronjonp

  • Needs a day job
  • Posts: 7529
Re: How do I find the location of MyDocuments folder?
« Reply #10 on: April 19, 2011, 04:52:43 PM »
I believe this returns the "Start in" folder specified in the shortcut used to start acad.

Looks to be the case here. Thanks Jeff.

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

laidbacklarry

  • Guest
Re: How do I find the location of MyDocuments folder?
« Reply #11 on: April 19, 2011, 06:04:42 PM »
(findfile ".") is interesting.

This goes back to the days of DOS. Every directory (folder) contains two "files" - A single dot represents the "current" directory (folder); two dots represents the parent of the current directory (folder), i.e., the part of the path returned by single dot with the current directory chopped off. And while that is initally the "Start in" folder listed in the ACAD shortcut, some commands, such as SAVEAS, can change the current directory to whatever directory is selected for the "Save to". This can be very bothersome when some user settings are predicated on the current directory always being the Start in folder.

alanjt

  • Needs a day job
  • Posts: 5352
  • Standby for witty remark...
Re: How do I find the location of MyDocuments folder?
« Reply #12 on: April 19, 2011, 06:44:59 PM »
(findfile ".") is interesting.

This goes back to the days of DOS. Every directory (folder) contains two "files" - A single dot represents the "current" directory (folder); two dots represents the parent of the current directory (folder), i.e., the part of the path returned by single dot with the current directory chopped off. And while that is initally the "Start in" folder listed in the ACAD shortcut, some commands, such as SAVEAS, can change the current directory to whatever directory is selected for the "Save to". This can be very bothersome when some user settings are predicated on the current directory always being the Start in folder.
Very interesting. I never considered the days of running DOS and typing cd.. to back up one directory folder.
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Re: How do I find the location of MyDocuments folder?
« Reply #13 on: April 19, 2011, 07:27:21 PM »
I'd probably go with the SpecialFolders object, but for more cat-skinning:

Code: [Select]
(vl-registry-read "HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders" "Personal")

JohnK

  • Administrator
  • Seagull
  • Posts: 10648
Re: How do I find the location of MyDocuments folder?
« Reply #14 on: April 19, 2011, 07:52:36 PM »
What do you mean `dos days' (I sense some nostalgia). ...I still use those dots.

My entry.
(getstring "\nEnter the path to your \"My Documents\" folder: ")


:p
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org