This repository has been archived by the owner on Jun 6, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix launching and detecting Battle.net games
- Loading branch information
Showing
4 changed files
with
147 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
param ( | ||
[Parameter(Mandatory=$True)][string]$bnet, # Path to the Battle.net executable | ||
[Parameter(Mandatory=$True)][string]$launchid # Battle.net launch id to launch | ||
) | ||
|
||
Write-Host 'Starting Battle.net' | ||
Start-Process $bnet | ||
|
||
# Wait to be sure log file gets created (just to be safe, usually gets created instantly) | ||
Start-Sleep -Seconds 3 | ||
|
||
# Get latest log file | ||
$log = Get-ChildItem -Path "$env:LOCALAPPDATA\Battle.net\Logs" -Filter "battle.net-*.log" | Sort-Object LastAccessTime -Descending | Select-Object -First 1 | ||
|
||
$bnetStarted = $False | ||
|
||
Write-Host 'Waiting for Battle.net to start completely' | ||
|
||
# Get current system date | ||
$currentDate = Get-Date | ||
Do { | ||
# Check log file until we find this string | ||
$launchedCompletely = Select-String -path $log -pattern 'GameController initialization complete' | ||
|
||
If (!($launchedCompletely)) { | ||
# Timeout after 1 minute | ||
If ($currentDate.AddMinutes(1) -lt (Get-Date)) | ||
{ | ||
Write-Host 'Could not find successful launch' | ||
exit | ||
} | ||
Start-Sleep -Seconds 1 | ||
} Else { | ||
Write-Host 'Bnet started!' | ||
$bnetStarted = $True | ||
} | ||
} Until ($bnetStarted) | ||
|
||
# Launch | ||
Write-Host "Starting game ($launchid)" | ||
Start-Process $bnet "--exec=`"launch $launchid`"" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters