param([switch]$CheckOnly) $ErrorActionPreference='Stop' $packageRoot=[IO.Path]::GetFullPath($PSScriptRoot) $packages=@( @{Name='Galaxy USB3 Vision';Inf='runtime\GalaxySDK\Drivers\Win64\GxU3VBase\GxU3VBase.inf';Cat='runtime\GalaxySDK\Drivers\Win64\GxU3VBase\gxu3vbase.cat'}, @{Name='Prolific PL2303GT';Inf='runtime\SerialDrivers\plser_1.inf';Cat='runtime\SerialDrivers\plser_1.cat'}, @{Name='CH340/CH341 serial';Inf='runtime\SerialDrivers\ch341ser.inf';Cat='runtime\SerialDrivers\CH341SER.CAT'} ) foreach($package in $packages){foreach($key in @('Inf','Cat')){if(-not(Test-Path -LiteralPath (Join-Path $packageRoot $package[$key]))){throw "Driver package missing: $($package[$key])"}}} if($CheckOnly){foreach($package in $packages){$signature=Get-AuthenticodeSignature -LiteralPath (Join-Path $packageRoot $package.Cat);Write-Host "$($package.Name): catalog=$($signature.Status), INF=$($package.Inf)"};exit 0} $identity=[Security.Principal.WindowsIdentity]::GetCurrent() $administrator=(New-Object Security.Principal.WindowsPrincipal($identity)).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator) if(-not $administrator){ $arguments='-NoProfile -ExecutionPolicy Bypass -File "'+$PSCommandPath+'"' $process=Start-Process -FilePath 'powershell.exe' -ArgumentList $arguments -Verb RunAs -WindowStyle Hidden -Wait -PassThru Write-Host "Driver installation exit code: $($process.ExitCode). See user_data\driver_install.log." exit $process.ExitCode } $logFolder=Join-Path $packageRoot 'user_data';New-Item -ItemType Directory -Force -Path $logFolder | Out-Null Start-Transcript -Path (Join-Path $logFolder 'driver_install.log') -Append | Out-Null $failed=$false try { foreach($package in $packages){ Write-Host "Installing $($package.Name)..." & "$env:SystemRoot\System32\pnputil.exe" /add-driver (Join-Path $packageRoot $package.Inf) /install if($LASTEXITCODE -notin @(0,3010)){Write-Warning "Driver installation failed: $($package.Name), exit=$LASTEXITCODE";$failed=$true} elseif($LASTEXITCODE -eq 3010){Write-Host 'Windows requests a restart to complete this installation.'} } & "$env:SystemRoot\System32\pnputil.exe" /enum-devices /class Ports /connected }finally{Stop-Transcript | Out-Null} if($failed){exit 1} Write-Host 'Driver packages installed/staged. Connect the camera and light USB adapter, then select the actual COM port in the software.' exit 0