Folder, file and permissions.

Folder, file and permissions.

carlos_m_gil_p
Advocate Advocate
880 Views
7 Replies
Message 1 of 8

Folder, file and permissions.

carlos_m_gil_p
Advocate
Advocate

Hello how are you.
I wanted to ask you how I can create a folder in the program files directory, but without administrator permissions I can't do it.

 

(if (null (vl-file-directory-p "C:\Program Files (x86)\myfolder")) 
  (vl-mkdir "C:\Program Files (x86)\myfolder"))


I want to create a folder in program files and then save a file to it

 

C:\Program Files (x86)\myfolder\myfile.txt

myfile.txt can have any other extension you need.

 

Try the @ronjonp function that I found in

 

https://www.cadtutor.net/forum/topic/64643-get-admin-access-with-autolisp/

 

But I can't make it work.
I don't understand why it doesn't work?

 

I use windows 10
Autocad 2022

 

Thanks for your help.


AutoCAD 2026
Visual Studio Code 1.99.3
AutoCAD AutoLISP Extension 1.6.3
Windows 10 (64 bits)

0 Likes
881 Views
7 Replies
Replies (7)
Message 2 of 8

john.uhden
Mentor
Mentor

Since you are using AutoLisp functions, try substituting double backslashes "\\" for every single backslash "\"

That's the way this language works.

OR

You could substitute a single foreslash "/" for every single backslash "\"

John F. Uhden

0 Likes
Message 3 of 8

Anonymous
Not applicable

A dumb answer create it some where else were you dont have problems creating, just add the location to support and trusted paths.

 

Something went wrong posted by seahaven.

0 Likes
Message 4 of 8

pbejse
Mentor
Mentor

@carlos_m_gil_p wrote:

Hello how are you.
I wanted to ask you how I can create a folder in the program files directory, but without administrator permissions I can't do it.

 

(if (null (vl-file-directory-p "C:\Program Files (x86)\myfolder")) 
  (vl-mkdir "C:\Program Files (x86)\myfolder"))


I want to create a folder in program files and then save a file to it

C:\Program Files (x86)\myfolder\myfile.txt

 

Curious is to why on that folder?  while you can use the appdata folder, this allows windows programs to store multiple sets of settings  as per users account.

 

(if (null
      (vl-file-directory-p
	(setq sourceFolder (strcat (getenv "APPDATA") "\\Myfolder"))
      )
    )
   (vl-mkdir sourceFolder))

 

 

 

0 Likes
Message 5 of 8

carlos_m_gil_p
Advocate
Advocate

Hi guys, how are you, thanks for the answers.
At one time I had a fas that created a file in a folder without permissions and I have to do the permissions manually.
But he made me curious about how to do the permits.
It is a subject to learn and apply in the future.


AutoCAD 2026
Visual Studio Code 1.99.3
AutoCAD AutoLISP Extension 1.6.3
Windows 10 (64 bits)

0 Likes
Message 6 of 8

ronjonp
Mentor
Mentor

I think that permissions code only worked in older versions of Windows. Like @pbejse mentioned, put your data somewhere else that isn't as locked down. It will serve you well not having to deal messing with permissions.

Message 7 of 8

carlos_m_gil_p
Advocate
Advocate

Hi guys, thanks for the replies.
I will continue investigating to see what other option I get.
Greetings.


AutoCAD 2026
Visual Studio Code 1.99.3
AutoCAD AutoLISP Extension 1.6.3
Windows 10 (64 bits)

0 Likes
Message 8 of 8

pbejse
Mentor
Mentor

@carlos_m_gil_p wrote:

I will continue investigating to see what other option I get.


 

Let us know how it goes @carlos_m_gil_p 

 

Cheers

 

0 Likes