diff --git a/ostp-gui/src-tauri/src/lib.rs b/ostp-gui/src-tauri/src/lib.rs index c8cb2ee..b979a49 100644 --- a/ostp-gui/src-tauri/src/lib.rs +++ b/ostp-gui/src-tauri/src/lib.rs @@ -768,7 +768,12 @@ fn launch_as_admin(exe: &std::path::PathBuf, token: &str, port: u16) -> anyhow:: let cwd_path = std::env::current_exe().unwrap_or_else(|_| std::path::PathBuf::from(".")); let dir_wstr: Vec = cwd_path.parent().unwrap_or(std::path::Path::new(".")).as_os_str().encode_wide().chain(Some(0)).collect(); - let ret = unsafe { ShellExecuteW(null_mut(), verb_wstr.as_ptr(), exe_wstr.as_ptr(), params_wstr.as_ptr(), dir_wstr.as_ptr(), 0) }; + // Remove Mark of the Web (Zone.Identifier) so SmartScreen doesn't block UAC + let zone_id = format!("{}:Zone.Identifier", exe.display()); + let _ = std::fs::remove_file(zone_id); + + // Use SW_SHOWNORMAL (1) instead of SW_HIDE (0) because runas with SW_HIDE is automatically blocked by UAC + let ret = unsafe { ShellExecuteW(null_mut(), verb_wstr.as_ptr(), exe_wstr.as_ptr(), params_wstr.as_ptr(), dir_wstr.as_ptr(), 1) }; // ShellExecuteW's return is a pseudo-HINSTANCE: > 32 means the call itself // "succeeded" — but that range INCLUDES ERROR_CANCELLED (1223), which is diff --git a/ostp-gui/src/index.html b/ostp-gui/src/index.html index 411112b..9c84311 100644 --- a/ostp-gui/src/index.html +++ b/ostp-gui/src/index.html @@ -280,10 +280,11 @@ - + +
OSTP GUI
- - + +