diff options
| author | Sebastian Holmin <sebastian.holmin@mullvad.net> | 2025-07-11 10:15:48 +0200 |
|---|---|---|
| committer | Sebastian Holmin <sebastian.holmin@mullvad.net> | 2025-07-11 10:15:48 +0200 |
| commit | 04e07b831e66e8461d9d6dcd6217a90f6db1d3e2 (patch) | |
| tree | 45566123976ffba5101d68a1e003c93e9bfe0ac6 /test/test-runner/src/sys.rs | |
| parent | 62ad63a99a450a31c484316d0ddd424d9ff7192d (diff) | |
| parent | 2985cf50fc64a715767e4d3e3617933804e42af0 (diff) | |
| download | mullvadvpn-04e07b831e66e8461d9d6dcd6217a90f6db1d3e2.tar.xz mullvadvpn-04e07b831e66e8461d9d6dcd6217a90f6db1d3e2.zip | |
Merge branch 'e2e-failed-upgrades-only-softlock'
Diffstat (limited to 'test/test-runner/src/sys.rs')
| -rw-r--r-- | test/test-runner/src/sys.rs | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/test/test-runner/src/sys.rs b/test/test-runner/src/sys.rs index a20a84cbaa..3490353b55 100644 --- a/test/test-runner/src/sys.rs +++ b/test/test-runner/src/sys.rs @@ -284,6 +284,51 @@ pub async fn start_app() -> Result<(), test_rpc::Error> { Ok(()) } +/// Disable the Mullvad VPN system service startup. This will not trigger the service to stop +/// immediately, but it will prevent it from starting on the next system boot. +#[cfg(target_os = "windows")] +pub async fn disable_system_service_startup() -> Result<(), test_rpc::Error> { + let status = tokio::process::Command::new("powershell") + .args([ + "-NoProfile", + "-Command", + "Set-Service -Name MullvadVPN -StartupType Disabled", + ]) + .status() + .await + .map_err(|e| test_rpc::Error::ServiceChange(e.to_string()))?; + + if !status.success() { + return Err(test_rpc::Error::ServiceChange( + "Failed to disable MullvadVPN service".to_string(), + )); + } + + Ok(()) +} + +/// Enable the Mullvad VPN system service startup. This will configure the service to start automatically on system boot. +#[cfg(target_os = "windows")] +pub async fn enable_system_service_startup() -> Result<(), test_rpc::Error> { + let status = tokio::process::Command::new("powershell") + .args([ + "-NoProfile", + "-Command", + "Set-Service -Name MullvadVPN -StartupType Automatic", + ]) + .status() + .await + .map_err(|e| test_rpc::Error::ServiceChange(e.to_string()))?; + + if !status.success() { + return Err(test_rpc::Error::ServiceChange( + "Failed to enable MullvadVPN service".to_string(), + )); + } + + Ok(()) +} + /// Restart the Mullvad VPN application. /// /// This function waits for the app to successfully start again. |
