30 lines
1.8 KiB
PowerShell
30 lines
1.8 KiB
PowerShell
param(
|
|
[string]$GameExecutable = 'C:\Program Files (x86)\DODI-Repacks\American Truck Simulator\bin\win_x64\amtrucks.exe',
|
|
[string]$PythonExecutable = 'C:\Python314\pythonw.exe'
|
|
)
|
|
$ErrorActionPreference = 'Stop'
|
|
$atsRoot = Split-Path -Parent $PSScriptRoot
|
|
$atsWatcher = Join-Path $PSScriptRoot 'ats_autostart.py'
|
|
foreach ($atsRequiredPath in @($GameExecutable, $PythonExecutable, $atsWatcher)) {
|
|
if (-not (Test-Path -LiteralPath $atsRequiredPath -PathType Leaf)) { throw "Missing launcher component: $atsRequiredPath" }
|
|
}
|
|
$atsShell = New-Object -ComObject WScript.Shell
|
|
$atsStartupLink = Join-Path ([Environment]::GetFolderPath('Startup')) 'ATS Native FSD Companion.lnk'
|
|
$atsDesktopLink = Join-Path ([Environment]::GetFolderPath('Desktop')) 'Tesla Semi FSD.lnk'
|
|
foreach ($atsLinkPath in @($atsStartupLink, $atsDesktopLink)) {
|
|
if ((Test-Path -LiteralPath $atsLinkPath) -and -not (Test-Path -LiteralPath "$atsLinkPath.before-autostart.bak")) {
|
|
Copy-Item -LiteralPath $atsLinkPath -Destination "$atsLinkPath.before-autostart.bak"
|
|
}
|
|
$atsShortcut = $atsShell.CreateShortcut($atsLinkPath)
|
|
$atsShortcut.TargetPath = $PythonExecutable
|
|
$atsShortcut.Arguments = '-B "{0}" --game "{1}"' -f $atsWatcher, $GameExecutable
|
|
if ($atsLinkPath -eq $atsDesktopLink) { $atsShortcut.Arguments += ' --launch' }
|
|
$atsShortcut.WorkingDirectory = $atsRoot
|
|
$atsShortcut.IconLocation = "$GameExecutable,0"
|
|
$atsShortcut.Description = 'ATS with automatic native driving and Tesla Semi cab screens'
|
|
$atsShortcut.Save()
|
|
}
|
|
Start-Process -FilePath $PythonExecutable -ArgumentList ('-B "{0}" --game "{1}"' -f $atsWatcher, $GameExecutable) -WorkingDirectory $atsRoot -WindowStyle Hidden
|
|
Write-Output "Installed login watcher: $atsStartupLink"
|
|
Write-Output "Installed one-click launcher: $atsDesktopLink"
|