Reputation: 64
Am trying to run a command file (which copy a file to /etc/dotnet folder which require admin privilege) from my application on Mac OS(Catalina). But when I am doing it ugly terminal comes up prompting for password to proceed. It kills my beautiful UI app. In Windows I can run the application by right click and "Run as administrator" option so that application itself run with privilege. Is there any way to do the similar thing in Mac OS app?
Thanks in advance, Raj
Upvotes: 1
Views: 9486
Reputation: 177
Open Terminal
and execute the following command (let's assume adminuser is a user account with administrator privileges):
$ sudo chown adminuser path-to-the-command-file
$ sudo chmod u+s path-to-the-command-file
The first command will make adminuser the owner of the file.
The second command will ensure that the file will execute with the file owner's user ID, and not the user running it (note that this will still pop-up a dialog asking for the admin password.)
(Try exploring ways to not copy something to /etc/dotnet if you totally want to avoid such things).
Upvotes: 0