Input the current user's username into a file path

Input the current user's username into a file path

cchiles
Enthusiast Enthusiast
324 Views
4 Replies
Message 1 of 5

Input the current user's username into a file path

cchiles
Enthusiast
Enthusiast

Hi, I have what I believe will be a simple question - or not:

If I set the following first:

(setq user (getvar 'loginname))

 

How do I go about inputting "user" into the following path:

(setvar "trustedpaths" "C:\\<HERE>\\OneDrive;
")

 

Or if there is a simpler way to input the current windows login username into a support path file path I would love to know it.

Thanks very much,

Chris

Thanks in advance!
-Chris
0 Likes
325 Views
4 Replies
Replies (4)
Message 2 of 5

Sea-Haven
Mentor
Mentor

You can add paths on the fly

 

(setq *files*  (vla-get-files  (vla-get-preferences (vlax-get-Acad-object))))
(setq paths (vla-get-SupportPath *files*))
(vla-put-SupportPath *files* (strcat user ";" paths))

(setq oldtrust (getvar 'trustedpaths))
(setvar 'trustedpaths (strcat oldtrust ";" user))
0 Likes
Message 3 of 5

paullimapa
Mentor
Mentor

and to add to @Sea-Haven 's solution you should check to see if user is already there in the trustedpaths before adding:

(if (not (wcmatch (getvar"trustedpaths") (strcat"*C:\\" user "\\OneDrive*")))

 (setvar 'trustedpaths (strcat oldtrust ";C:\\" user "\\OneDrive"))

)


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes
Message 4 of 5

john.uhden
Mentor
Mentor

@paullimapa ,

Be careful there, Paulli.

wcmatch treats case as sensitive.

(setq this "A;B;OneDrive;C" that "*onedrive*")

(wcmatch this that) returns nil.

But

(wcmatch (strcase this) (strcase that)) returns T

 

John F. Uhden

0 Likes
Message 5 of 5

paullimapa
Mentor
Mentor

Yes @john.uhden ... good catch on that. You are absolutely correct 


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes