我正在尝试停止并启动com.apple.mobile.installd从我的应用程序,是为越狱手机。我尝试了几乎所有可能的方式-- NSTask、system()、shell脚本--但它不起作用。有人能帮我吗??
下面是我尝试过的代码示例。
-(IBAction)stopIntl:(id)sender
{
NSString *command = [NSString stringWithFormat:@"/bin/launchctl stop com.apple.mobile.installd >> /Applications/loader.app/output.txt"];
const char* new = [command UTF8String];
system(new);
NSLog(@"Stopping InstallD");
}
-(IBAction)startIntl:(id)sender
{
NSString *command = [NSString stringWithFormat:@"/bin/launchctl start com.apple.mobile.installd >> /Applications/loader.app/output.txt"];
const char* new = [command UTF8String];
system(new);
NSLog(@"Starting InstallD");
}
-(IBAction)reloadShell:(id)sender
{
system("/bin/launchctl stop com.apple.mobile.installd");
sleep(2);
system("/bin/launchctl start com.apple.mobile.installd");
NSLog(@"Reloading Shell");
}
-(IBAction)reloadShell1:(id)sender
{
NSString *command = [NSString stringWithFormat:@"/usr/libexec/reload.sh >> /Applications/loader.app/output.txt"];
system([command UTF8String]);
NSLog(@"Reloading Shell1");
}我的reload.sh --它在终端机上工作..。
#!/bin/sh
# reload.sh
#
# Copyright (c) 2014 Avanté Codeworx. All #rights reserved.
launchctl stop com.apple.mobile.installd
sleep 2
launchctl start com.apple.mobile.installd
exit从过去的十天开始我的头被撞了,还试着发射守护进程--它能工作,但能继续运行..永不倒下..。
这是我的守护进程。
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>LaunchEvents</key>
<dict>
<key>com.apple.notifyd.matching</key>
<dict>
<key>com.loader.reload</key>
<dict>
<key>Notification</key>
<string>com.loader.reload</string>
</dict>
</dict>
</dict>
<key>Label</key>
<string>com.avante.loader</string>
<key>UserName</key>
<string>root</string>
<key>KeepAlive</key>
<false/>
<key>Program</key>
<string>/usr/libexec/reload.sh</string>
</dict>
</plist>请帮帮我!!
发布于 2014-02-09 10:04:29
这是一些人的误解。
就因为你的手机坏了,apps don't run with root privileges。
仅仅因为您的应用程序安装在/Applications/中,它就不会以root权限运行。
若要使应用程序以root权限运行,see this answer。否则,它将以用户mobile的身份运行。
launchctl需要root特权才能正常工作。
当然,您也可以删除启动守护进程。正确的方法是给你的应用程序根目录特权。
https://stackoverflow.com/questions/21632449
复制相似问题