Shell to Disable/Enable Gatekeeper?

Hello,

I found this link…
http://osxdaily.com/2016/09/27/allow-apps-from-anywhere-macos-gatekeeper/
which allows the user to Disable and Enable gatekeeper via Terminal.

How could I code that in my app so that I do not have to open Terminal?

I have this…

        Dim GatekeeperCommand as String = "sudo spctl --master-disable"
        Dim GatekeeperShell as new Shell
        GatekeeperShell.Execute GatekeeperCommand

I am aware that the password somehow has to be added.

Thanks.

Lennox

AFAIK you cannot sudo from shell, and Terminal is not scriptable.

You know, the best way to have Gatekeeper leave you alone is to sign your application.

Thanks Michel
Lennox

When Gatekeeper got locked down, Apple also locked sudo down by setting the requiretty sudo flag so that you can’t using the old sudo -S option to pass the password through as an argument like this:

echo thePassword | sudo -S /usr/bin/true (works through 10.9 and some 10.10)

You could get the user to modify their /private/etc/sudoers file, but that requires the same level of access as asking them to run that sptcl command.

As Michel states, the best answer is to codesign your apps