Skip to content

Commit

Permalink
fix(msix): not showing admin prompt
Browse files Browse the repository at this point in the history
  • Loading branch information
eythaann committed Feb 6, 2025
1 parent b561b2e commit f01e1a3
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 9 deletions.
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
### fix
- devices and battery not clickables on toolbar.
- missing icon on dock media module while not playing.
- msix store not showing admin prompt.

## [2.1.4]
### fix
Expand Down
27 changes: 18 additions & 9 deletions src/background/modules/cli/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,14 @@ use application::{get_app_command, handle_cli_events};
pub use domain::SvcAction;
use domain::SvcMessage;
use itertools::Itertools;
use tauri_plugin_dialog::{DialogExt, MessageDialogKind};
use windows::Win32::System::TaskScheduler::{IExecAction2, ITaskService, TaskScheduler};
use windows_core::Interface;

use crate::{
error_handler::Result,
log_error,
seelen::Seelen,
seelen::{get_app_handle, Seelen},
utils::{pwsh::PwshScript, spawn_named_thread},
windows_api::Com,
};
Expand Down Expand Up @@ -168,15 +169,23 @@ impl ServiceClient {
// so if the service is not running, we need to start it (common on msix setup)
pub async fn start_service() -> Result<()> {
if let Err(err) = Self::start_service_task() {
log::debug!("Can not start service via task: {}", err);
log::debug!("Can not start service via task scheduler: {}", err);
let service_path = std::env::current_exe()?.with_file_name("slu-service.exe");
PwshScript::new(format!(
"Start-Process '{}' -Verb runAs",
service_path.display(),
))
.inline_command()
.execute()
.await?;
let script = PwshScript::new(format!("&\"{}\"", service_path.display(),)).elevated();
let result = script.execute().await;
if let Err(err) = result {
let try_again = get_app_handle()
.dialog()
.message(t!("service.not_running_description"))
.title(t!("service.not_running"))
.kind(MessageDialogKind::Info)
.ok_button_label(t!("service.not_running_ok"))
.blocking_show();
if try_again {
script.execute().await?;
}
return Err(err);
}
}
Ok(())
}
Expand Down

0 comments on commit f01e1a3

Please sign in to comment.