Skip to content

Commit

Permalink
opt: uniform install process with flutter in sciter
Browse files Browse the repository at this point in the history
  • Loading branch information
Kingtous committed May 14, 2023
1 parent 400aa61 commit 6af1926
Showing 1 changed file with 0 additions and 35 deletions.
35 changes: 0 additions & 35 deletions src/platform/windows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -903,7 +903,6 @@ fn get_install_info_with_subkey(subkey: String) -> (String, String, String, Stri
}

pub fn copy_raw_cmd(src_raw: &str, _raw: &str, _path: &str) -> String {
#[cfg(feature = "flutter")]
let main_raw = format!(
"XCOPY \"{}\" \"{}\" /Y /E /H /C /I /K /R /Z",
PathBuf::from(src_raw)
Expand All @@ -913,12 +912,6 @@ pub fn copy_raw_cmd(src_raw: &str, _raw: &str, _path: &str) -> String {
.to_string(),
_path
);
#[cfg(not(feature = "flutter"))]
let main_raw = format!(
"copy /Y \"{src_raw}\" \"{raw}\"",
src_raw = src_raw,
raw = _raw
);
return main_raw;
}

Expand All @@ -939,31 +932,17 @@ pub fn copy_exe_cmd(src_exe: &str, exe: &str, path: &str) -> String {
pub fn update_me() -> ResultType<()> {
let (_, path, _, exe, _dll) = get_install_info();
let src_exe = std::env::current_exe()?.to_str().unwrap_or("").to_owned();
#[cfg(not(feature = "flutter"))]
let src_dll = std::env::current_exe()?
.parent()
.unwrap_or(&Path::new(&get_default_install_path()))
.join("sciter.dll")
.to_str()
.unwrap_or("")
.to_owned();
#[cfg(feature = "flutter")]
let copy_dll = "".to_string();
#[cfg(not(feature = "flutter"))]
let copy_dll = copy_raw_cmd(&src_dll, &_dll, &path);
let cmds = format!(
"
chcp 65001
sc stop {app_name}
taskkill /F /IM {broker_exe}
taskkill /F /IM {app_name}.exe /FI \"PID ne {cur_pid}\"
{copy_exe}
{copy_dll}
sc start {app_name}
{lic}
",
copy_exe = copy_exe_cmd(&src_exe, &exe, &path),
copy_dll = copy_dll,
broker_exe = WIN_MAG_INJECTED_PROCESS_EXE,
app_name = crate::get_app_name(),
lic = register_licence(),
Expand Down Expand Up @@ -1133,18 +1112,6 @@ if exist \"{tmp_path}\\{app_name} Tray.lnk\" del /f /q \"{tmp_path}\\{app_name}
app_name = crate::get_app_name(),
);
let src_exe = std::env::current_exe()?.to_str().unwrap_or("").to_string();
#[cfg(not(feature = "flutter"))]
let src_dll = std::env::current_exe()?
.parent()
.unwrap_or(&Path::new(&get_default_install_path()))
.join("sciter.dll")
.to_str()
.unwrap_or("")
.to_owned();
#[cfg(feature = "flutter")]
let copy_dll = "".to_string();
#[cfg(not(feature = "flutter"))]
let copy_dll = copy_raw_cmd(&src_dll, &_dll, &path);

let install_cert = if options.contains("driverCert") {
format!("\"{}\" --install-cert \"RustDeskIddDriver.cer\"", src_exe)
Expand All @@ -1158,7 +1125,6 @@ if exist \"{tmp_path}\\{app_name} Tray.lnk\" del /f /q \"{tmp_path}\\{app_name}
chcp 65001
md \"{path}\"
{copy_exe}
{copy_dll}
reg add {subkey} /f
reg add {subkey} /f /v DisplayIcon /t REG_SZ /d \"{exe}\"
reg add {subkey} /f /v DisplayName /t REG_SZ /d \"{app_name}\"
Expand Down Expand Up @@ -1218,7 +1184,6 @@ sc delete {app_name}
&dels
},
copy_exe = copy_exe_cmd(&src_exe, &exe, &path),
copy_dll = copy_dll
);
run_cmds(cmds, debug, "install")?;
std::thread::sleep(std::time::Duration::from_millis(2000));
Expand Down

0 comments on commit 6af1926

Please sign in to comment.