forked from DiscordDigital/AltCheck-Reborn
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAltCheck-Reborn.ps1
More file actions
58 lines (52 loc) · 2.13 KB
/
AltCheck-Reborn.ps1
File metadata and controls
58 lines (52 loc) · 2.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
param ($monitoriDeviceInterval=120, $successInterval = 60, $iMobileDeviceFolder="imobiledevice", $altServerPath="C:\Program Files (x86)\AltServer\AltServer.exe", $appleServiceName="Apple Mobile Device Service")
$version = "1.0"
Set-Location -Path $PsScriptRoot
function startAltServer {
Write-Host $(Get-Date) [ACTION] Started AltServer
Start-Process $altServerPath
}
function checkAltServer {
$process = Get-Process AltServer -ErrorAction SilentlyContinue
if ($process) {
return $true;
} else {
return $false;
}
}
function restartAppleMobileDeviceService {
Write-Host $(Get-Date) [INFO] Restarting $appleServiceName
try {
Restart-Service -Name $appleServiceName -ErrorAction Stop
Write-Host $(Get-Date) [OK] Action completed
Write-Host $(Get-Date) [INFO] Waiting $monitoriDeviceInterval seconds before $appleServiceName attempts detecting iPhone
} catch {
Write-Host $(Get-Date) [ERROR] Cannot restart $appleServiceName. Try running this script as Administrator.
Write-Host $(Get-Date) [INFO] Waiting $monitoriDeviceInterval seconds before attempting again.
Write-Host $(Get-Date) [INFO] Grab the latest version on GitHub: https://github.com/DiscordDigital
}
Start-Sleep $monitoriDeviceInterval
}
while($true) {
$deviceCount = 0
Write-Host $(Get-Date) [INFO] Checking AltServer
$altServerStatus = checkAltServer
if ($altServerStatus) {
Write-Host $(Get-Date) [INFO] AltServer is running
}
else {
Write-Host $(Get-Date) [INFO] AltServer is not running. Calling startAltServer
startAltServer
}
Write-Host $(Get-Date) [INFO] Checking $appleServiceName
# $deviceCount = ("$iMobileDeviceFolder\idevice_id.exe -l" | Measure-Object).Count
$deviceCount = (cmd /c $iMobileDeviceFolder\idevice_id.exe -l).Count
if ($deviceCount -lt 1) {
Write-Host $(Get-Date) [WARN] No devices found. Restarting $appleServiceName
restartAppleMobileDeviceService
} else {
Write-Host $(Get-Date) [INFO] $deviceCount devices found. No action needed.
Write-Host $(Get-Date) [INFO] Waiting for $successInterval seconds before checking again.
Start-Sleep $successInterval
}
Write-Host
}