Skip to content

armgit / cua

Public Imported from GitHub
0

Scale computer-use 2.0 with open-source drivers, cross-OS sandboxes, and benchmarks for training, evaluation, and data generation.

fix(cua-driver): preserve Windows autostart path quoting

Francesco Bonaccicf07c2c9ef7b
diff --git a/.github/scripts/tests/test_cua_driver_release_wiring.py b/.github/scripts/tests/test_cua_driver_release_wiring.py
index 5daf8d4091..25f02de32e 100644
--- a/.github/scripts/tests/test_cua_driver_release_wiring.py
+++ b/.github/scripts/tests/test_cua_driver_release_wiring.py
@@ -268,6 +268,27 @@ class TestCuaDriverReleaseWiring(unittest.TestCase):
self.assertIn('$CursorThemeRequiredFrom = [version]"0.12.7"', powershell)
self.assertIn("[version]$version -ge $CursorThemeRequiredFrom", powershell)
+ def test_windows_installer_elevates_autostart_binary_without_command_string(
+ self,
+ ) -> None:
+ powershell = self.read("libs/cua-driver/scripts/install.ps1")
+ block = powershell.split(
+ "function Register-CuaDriverAutostart {", maxsplit=1
+ )[1].split(
+ "# ---------- Concurrent-install lockfile", maxsplit=1
+ )[0]
+
+ self.assertIn(
+ "Start-Process -FilePath $InstalledBinary",
+ block,
+ )
+ self.assertIn(
+ '-ArgumentList @("autostart", "enable")',
+ block,
+ )
+ self.assertNotIn("$elevCmd", block)
+ self.assertNotIn("Read-Host", block)
+
def test_local_installer_does_not_clean_release_or_legacy_homes(self) -> None:
installer = self.read("libs/cua-driver/scripts/_install-local-rust.sh")
diff --git a/libs/cua-driver/scripts/install.ps1 b/libs/cua-driver/scripts/install.ps1
index 619c0e3270..bf5b5089a8 100644
--- a/libs/cua-driver/scripts/install.ps1
+++ b/libs/cua-driver/scripts/install.ps1
@@ -622,10 +622,14 @@ function Register-CuaDriverAutostart {
Write-Host "The task itself runs silently at every logon afterwards." -ForegroundColor Yellow
Write-Host ""
- $elevCmd = "& `"$InstalledBinary`" autostart enable; `$ec = `$LASTEXITCODE; if (`$ec -ne 0) { Read-Host 'cua-driver autostart enable failed; press Enter to close' }; exit `$ec"
try {
- $proc = Start-Process -FilePath "powershell.exe" `
- -ArgumentList "-NoProfile","-ExecutionPolicy","Bypass","-Command",$elevCmd `
+ # Elevate the installed executable directly. Passing a quoted command
+ # string through Start-Process -ArgumentList loses the executable's
+ # outer quotes when PowerShell joins the arguments, so profile paths
+ # containing spaces are split before the elevated shell can invoke
+ # the binary.
+ $proc = Start-Process -FilePath $InstalledBinary `
+ -ArgumentList @("autostart", "enable") `
-Verb RunAs -Wait -PassThru -ErrorAction Stop
if ($proc.ExitCode -ne 0) {
throw "cua-driver autostart enable failed in elevated session (exit $($proc.ExitCode))"