When I run the following command on a command line, I am able to silently install the package but when I put t开发者_运维知识库he following code in a objective c program and run it. The package does not get installed.
Shell command -
echo password | sudo -S installer -pkg /Users/prashanth/Desktop/AppTest.mpkg -target /
Objective C -
system(@"echo password | sudo -S installer -pkg /Users/prashanth/Desktop/AppTest.mpkg -target /");
The system()
function does not take an NSString. Get rid of the @
.
However, I don't recommend this. It pretty much defeats the point of having an administrator password. Anyone with read access to the app binary or the ability to see just the names of running programs will be able to see the password in plaintext.
精彩评论