Files
kinect/attach/windows/scripts/Install-UsbIpWin.ps1
T
kinect-bot 9b5a0255e2
ci / Linux C++ core (cmake + ctest) (push) Canceled after 0s
ci / Python root tests (pytest, no tracker deps) (push) Canceled after 0s
ci / Python tracker (pytest, tracker/.venv) (push) Canceled after 0s
feat(windows): usbip-win runbook ([~]) + clean-room Kinect10.dll NUI shim (x86+x64 export-verified) (wave 9; todo 14 done, 12/13 blocked)
2026-11-25 06:00:12 -05:00

109 lines
5.3 KiB
PowerShell

#requires -Version 5.1
<#
.SYNOPSIS
Install a USB/IP VHCI client on this Windows box so it can attach the virtual Kinect v1
exported by the OS-agnostic attach/linux UsbipServer. Personal-use / test-signing only.
.DESCRIPTION
[~] BLOCKED in the kinect build environment (no Windows, no WDK). RUN THIS ON THE USER'S
WINDOWS BOX, from an elevated PowerShell (Run as Administrator).
Two supported clients (pick one with -Client):
* usbip-win2 (vadimgrn) -- RECOMMENDED. UDE driver, attestation/WHLK-signed, ships an MSI
installer. May not require test-signing at all. Download the MSI from
https://github.com/vadimgrn/usbip-win2/releases and pass its path with -InstallerPath.
* usbip-win (cezanne) -- legacy. Test-signed VHCI driver; REQUIRES test-signing ON and the
bundled test certificate installed (see Enable-TestSigning.ps1). Download the release zip
from https://github.com/cezanne/usbip-win/releases and extract it; pass the folder with
-PackageDir.
This script does NOT build either driver (that needs the WDK). It installs a prebuilt release.
.PARAMETER Client
'usbip-win2' (default) or 'usbip-win'.
.PARAMETER InstallerPath
usbip-win2 only: path to the downloaded USBip MSI.
.PARAMETER PackageDir
usbip-win only: folder containing the extracted release
(usbip.exe, usbip_vhci_ude.inf/.sys/.cat or usbip_vhci.inf/.sys/.cat, usbip_test.pfx).
.EXAMPLE
# Recommended, signed driver:
.\Install-UsbIpWin.ps1 -Client usbip-win2 -InstallerPath .\USBip-0.9.x.x64.msi
.EXAMPLE
# Legacy, test-signed driver (run Enable-TestSigning.ps1 first):
.\Install-UsbIpWin.ps1 -Client usbip-win -PackageDir .\usbip-win-0.3.6-dev
#>
[CmdletBinding()]
param(
[ValidateSet('usbip-win2', 'usbip-win')]
[string]$Client = 'usbip-win2',
[string]$InstallerPath,
[string]$PackageDir
)
$ErrorActionPreference = 'Stop'
function Assert-Admin {
$id = [Security.Principal.WindowsIdentity]::GetCurrent()
$principal = New-Object Security.Principal.WindowsPrincipal($id)
if (-not $principal.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) {
throw 'This script must run in an elevated PowerShell (Run as Administrator).'
}
}
Assert-Admin
Write-Host '=== Virtual Kinect v1 -- USB/IP VHCI client install ===' -ForegroundColor Cyan
Write-Host 'Create a System Restore Point first (installing a bus/host-controller driver restarts USB hubs).' -ForegroundColor Yellow
switch ($Client) {
'usbip-win2' {
if (-not $InstallerPath -or -not (Test-Path $InstallerPath)) {
throw "usbip-win2 needs -InstallerPath <USBip MSI>. Download it from https://github.com/vadimgrn/usbip-win2/releases"
}
Write-Host "Installing usbip-win2 from $InstallerPath ..." -ForegroundColor Green
$proc = Start-Process msiexec.exe -ArgumentList @('/i', "`"$InstallerPath`"", '/passive', '/norestart') -Wait -PassThru
if ($proc.ExitCode -ne 0 -and $proc.ExitCode -ne 3010) {
throw "msiexec returned $($proc.ExitCode)."
}
Write-Host 'usbip-win2 installed. usbip.exe is on PATH under "C:\Program Files\USBip".' -ForegroundColor Green
Write-Host 'If its UDE driver is attestation-signed, test-signing is NOT required. If Windows still refuses to load it,'
Write-Host 'run Enable-TestSigning.ps1 and reboot. Do NOT disable test-signing while a test-signed VHCI driver is installed.'
}
'usbip-win' {
if (-not $PackageDir -or -not (Test-Path $PackageDir)) {
throw "usbip-win needs -PackageDir <extracted release folder>. Download from https://github.com/cezanne/usbip-win/releases"
}
$usbip = Join-Path $PackageDir 'usbip.exe'
if (-not (Test-Path $usbip)) { throw "usbip.exe not found in $PackageDir." }
$udeInf = Join-Path $PackageDir 'usbip_vhci_ude.inf'
$wdmInf = Join-Path $PackageDir 'usbip_vhci.inf'
Write-Host 'Reminder: Enable-TestSigning.ps1 must have been run + rebooted, and usbip_test.pfx imported,' -ForegroundColor Yellow
Write-Host 'into BOTH "Trusted Root Certification Authorities" AND "Trusted Publishers" of the LOCAL COMPUTER store.' -ForegroundColor Yellow
Write-Host "Installing the usbip-win VHCI driver via '$usbip install' ..." -ForegroundColor Green
& $usbip install
if ($LASTEXITCODE -ne 0) {
# Fall back to manual pnputil add-driver (UDE first, then WDM).
if (Test-Path $udeInf) {
Write-Host 'usbip install failed; adding usbip_vhci_ude.inf via pnputil ...' -ForegroundColor Yellow
pnputil /add-driver $udeInf /install
} elseif (Test-Path $wdmInf) {
Write-Host 'usbip install failed; adding usbip_vhci.inf via pnputil ...' -ForegroundColor Yellow
pnputil /add-driver $wdmInf /install
} else {
throw 'No usbip_vhci_ude.inf or usbip_vhci.inf found to install.'
}
Write-Host 'If the device did not appear, finish via Device Manager > Action > Add legacy hardware > Have Disk > choose this folder.'
}
Write-Host "usbip-win VHCI client installed. Use '$usbip' for attach/detach." -ForegroundColor Green
}
}
Write-Host 'Next: start the attach/linux server on the host, then run Attach-Kinect.ps1.' -ForegroundColor Cyan