Start new process with admin rights on MAC

I am windows user. I am able to execute process as admin on windows like that

public void ExecuteAsAdmin(string fileName, string args)
{
    Process proc = new Process();
    proc.StartInfo.FileName = fileName;
    proc.StartInfo.UseShellExecute = true;
    proc.StartInfo.Verb = "runas";
    proc.StartInfo.Arguments = args;
    proc.Start();
}

Wit this code, UAC is triggered and everything is working as it should. Unfortunatelly, i am not able to achieve it on MAC. Do you know, whether/how can i achieve it?
Do i run SUDO app there with parameter?

Yes, you use the sudo command, but the account logged on to the machine needs to be an administrator account.

https://support.apple.com/en-us/HT202035

1 Like

So basically i fill startinfo filename with sudo and arguments with path to the application which i would like to run?

Yes. I don’t know how it’s handled on macOS but on Linux there will be a prompt that appears asking for a password. I don’t know if you can supply the password ahead of time to sudo.

Out of interest what do you need admin rights for your app? Sounds a bit, well sketchy? Could be legit OC. People get a bit unsure when the app needs to run a process under admin.

The app is updating itself (you need to have two apps actually), but you cannot overwrite the files unless you have admin rights

Just saw this not sure if it any use to you though or how decent it is - seems pretty old 2006 although last commit was 9 days ago?

https://sparkle-project.org/

I have found out, that you cannot just run sudo on its own. Any thoughts guys?

Skip Mac? :slight_smile:

i wish i could. I hate that system already

1 Like