Refact/printer driver default unchecked (#15191)
Some checks failed
Full Flutter CI / build-rustdesk-linux-sciter x86_64-unknown-linux-gnu (push) Has been skipped
Full Flutter CI / build-rustdesk-web (push) Failing after 0s
Full Flutter CI / generate_bridge (map[extra-build-args: os:ubuntu-22.04 target:x86_64-unknown-linux-gnu]) (push) Failing after 51s
Full Flutter CI / generate-bridge (push) Failing after 0s
Full Flutter CI / aarch64-apple-darwin (push) Has been skipped
Full Flutter CI / x86_64-apple-darwin (push) Has been skipped
Full Flutter CI / build rustdesk android apk aarch64-linux-android (push) Has been skipped
Full Flutter CI / build rustdesk android apk armv7-linux-androideabi (push) Has been skipped
Full Flutter CI / build rustdesk android apk x86_64-linux-android (push) Has been skipped
Full Flutter CI / build rustdesk linux aarch64-unknown-linux-gnu (push) Has been skipped
Full Flutter CI / build rustdesk linux x86_64-unknown-linux-gnu (push) Has been skipped
Full Flutter CI / build rustdesk android universal apk (push) Has been skipped
Full Flutter CI / Build appimage aarch64-unknown-linux-gnu (push) Has been skipped
CI / x86_64-unknown-linux-gnu (ubuntu-24.04) (push) Failing after 59s
Full Flutter CI / Build appimage x86_64-unknown-linux-gnu (push) Has been skipped
Full Flutter CI / run-ci (push) Has been cancelled
Full Flutter CI / build-RustDeskTempTopMostWindow (push) Has been cancelled
Full Flutter CI / x86_64-pc-windows-msvc (push) Has been cancelled
Full Flutter CI / i686-pc-windows-msvc (windows-2022) (push) Has been cancelled
Full Flutter CI / build rustdesk ios ipa (push) Has been cancelled
Full Flutter CI / publish_unsigned (push) Has been cancelled
Full Flutter CI / build-rustdesk-linux-sciter armv7-unknown-linux-gnueabihf (push) Has been cancelled
Full Flutter CI / Build flatpak aarch64-unknown-linux-gnu (push) Has been cancelled
Full Flutter CI / Build flatpak x86_64-unknown-linux-gnu (push) Has been cancelled
Full Flutter CI / Build flatpak x86_64-unknown-linux-gnu-sciter (push) Has been cancelled
Full Flutter CI / build-RustDeskTempTopMostWindow-1 (push) Has been cancelled
wf-cliprdr CI / wf_cliprdr invariant test (push) Has been cancelled

* refact: installation, printer driver, default unchecked

Signed-off-by: fufesou <linlong1266@gmail.com>

* refact: silent install, get option from the reg values

Signed-off-by: fufesou <linlong1266@gmail.com>

* refact: silent install, arg printer=[0|1]

Signed-off-by: fufesou <linlong1266@gmail.com>

---------

Signed-off-by: fufesou <linlong1266@gmail.com>
This commit is contained in:
fufesou 2026-06-06 08:51:08 +08:00 committed by GitHub
commit 6426269d41
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 50 additions and 14 deletions

View file

@ -65,7 +65,7 @@ class _InstallPageBodyState extends State<_InstallPageBody>
late final TextEditingController controller;
final RxBool startmenu = true.obs;
final RxBool desktopicon = true.obs;
final RxBool printer = true.obs;
final RxBool printer = false.obs;
final RxBool showProgress = false.obs;
final RxBool btnEnabled = true.obs;
@ -80,7 +80,7 @@ class _InstallPageBodyState extends State<_InstallPageBody>
final installOptions = jsonDecode(bind.installInstallOptions());
startmenu.value = installOptions['STARTMENUSHORTCUTS'] != '0';
desktopicon.value = installOptions['DESKTOPSHORTCUTS'] != '0';
printer.value = installOptions['PRINTER'] != '0';
printer.value = installOptions['PRINTER'] == '1';
}
@override

View file

@ -67,7 +67,7 @@
Some msi packages reset the `VersionNT` value to 1000 on Windows 10.
https://www.advancedinstaller.com/user-guide/qa-OS-dependent-install.html -->
<!-- Remote printer also works on Win8.1 in my test. -->
<Custom Action="InstallPrinter" Before="InstallFinalize" Condition="VersionNT &gt;= 603 AND PRINTER = 1 OR PRINTER = &quot;Y&quot; OR PRINTER = &quot;y&quot;" />
<Custom Action="InstallPrinter" Before="InstallFinalize" Condition="VersionNT &gt;= 603 AND (PRINTER = 1 OR PRINTER = &quot;Y&quot; OR PRINTER = &quot;y&quot;)" />
<Custom Action="InstallPrinter.SetParam" Before="InstallPrinter" Condition="VersionNT &gt;= 603" />
<!--Workaround of "fire:FirewallException". If Outbound="Yes" or Outbound="true", the following error occurs.-->

View file

@ -4,17 +4,17 @@
<?include ..\Includes.wxi?>
<!--
Properties and related actions for specifying whether to install start menu/desktop shortcuts.
Properties and related actions for specifying whether to install shortcuts and the printer.
-->
<!-- These are the actual properties that get used in conditions to determine whether to
install start menu shortcuts, they are initialized with a default value to install shortcuts.
They should not be set directly from the command line or registry, instead the CREATE* properties
below should be set, then they will update these properties with their values only if set. -->
install start menu shortcuts or the printer. Shortcut properties default to install;
PRINTER defaults to not install. The CREATE* properties below update shortcut
properties from command line, bundle, or registry values. -->
<Property Id="STARTMENUSHORTCUTS" Value="1" Secure="yes"></Property>
<Property Id="DESKTOPSHORTCUTS" Value="1" Secure="yes"></Property>
<Property Id="STARTUPSHORTCUTS" Value="1" Secure="yes"></Property>
<Property Id="PRINTER" Value="1" Secure="yes"></Property>
<Property Id="PRINTER" Secure="yes"></Property>
<!-- These properties get set from either the command line, bundle or registry value,
if set they update the properties above with their value. -->
@ -77,7 +77,11 @@
<!-- If a command line value or registry value was set, update the main properties with the value -->
<SetProperty Id="STARTMENUSHORTCUTS" Value="" After="RestoreSavedStartMenuShortcutsValue" Sequence="first" Condition="CREATESTARTMENUSHORTCUTS AND NOT (CREATESTARTMENUSHORTCUTS = 1 OR CREATESTARTMENUSHORTCUTS = &quot;Y&quot; OR CREATESTARTMENUSHORTCUTS = &quot;y&quot;)" />
<SetProperty Id="DESKTOPSHORTCUTS" Value="" After="RestoreSavedDesktopShortcutsValue" Sequence="first" Condition="CREATEDESKTOPSHORTCUTS AND NOT (CREATEDESKTOPSHORTCUTS = 1 OR CREATEDESKTOPSHORTCUTS = &quot;Y&quot; OR CREATEDESKTOPSHORTCUTS = &quot;y&quot;)" />
<SetProperty Id="PRINTER" Value="" After="RestoreSavedPrinterValue" Sequence="first" Condition="INSTALLPRINTER AND NOT (INSTALLPRINTER = 1 OR INSTALLPRINTER = &quot;Y&quot; OR INSTALLPRINTER = &quot;y&quot;)" />
<!-- PRINTER defaults to empty now, so a saved or command-line INSTALLPRINTER=1
must explicitly enable the main PRINTER property. Non-truthy INSTALLPRINTER
values still clear PRINTER so upgrades preserve an explicit disabled choice. -->
<SetProperty Action="SetPrinterValueEnabled" Id="PRINTER" Value="1" After="RestoreSavedPrinterValue" Sequence="first" Condition="INSTALLPRINTER = 1 OR INSTALLPRINTER = &quot;Y&quot; OR INSTALLPRINTER = &quot;y&quot;" />
<SetProperty Action="SetPrinterValueDisabled" Id="PRINTER" Value="" After="SetPrinterValueEnabled" Sequence="first" Condition="INSTALLPRINTER AND NOT (INSTALLPRINTER = 1 OR INSTALLPRINTER = &quot;Y&quot; OR INSTALLPRINTER = &quot;y&quot;)" />
</Fragment>
</Wix>

View file

@ -262,11 +262,9 @@ pub fn core_main() -> Option<Vec<String>> {
if config::is_disable_installation() {
return None;
}
#[cfg(not(windows))]
let options = "desktopicon startmenu";
#[cfg(windows)]
let options = "desktopicon startmenu printer";
let res = platform::install_me(options, "".to_owned(), true, args.len() > 1);
let (printer_override, debug) = parse_silent_install_args(&args);
let options = platform::get_silent_install_options(printer_override);
let res = platform::install_me(options, "".to_owned(), true, debug);
let text = match res {
Ok(_) => translate("Installation Successful!".to_string()),
Err(err) => {
@ -933,6 +931,23 @@ fn is_cli_setting_change_disabled() -> bool {
config::is_disable_settings() && !allow_command_line_settings
}
#[cfg(windows)]
fn parse_silent_install_args(args: &[String]) -> (Option<bool>, bool) {
let mut printer_override = None;
let mut debug = false;
for arg in args.iter().skip(1) {
match arg.as_str() {
"printer=1" => printer_override = Some(true),
"printer=0" => printer_override = Some(false),
"debug" => debug = true,
_ => {}
}
}
(printer_override, debug)
}
#[cfg(test)]
mod tests {
use super::*;

View file

@ -1324,6 +1324,23 @@ pub fn get_install_options() -> String {
serde_json::to_string(&opts).unwrap_or("{}".to_owned())
}
pub fn get_silent_install_options(printer_override: Option<bool>) -> &'static str {
let install_printer = match printer_override {
Some(override_value) => override_value,
None => {
let app_name = crate::get_app_name();
let subkey = format!(".{}", app_name.to_lowercase());
let printer = get_reg_of_hkcr(&subkey, REG_NAME_INSTALL_PRINTER);
printer.as_deref() == Some("1")
}
};
if install_printer && is_win_10_or_greater() {
"desktopicon startmenu printer"
} else {
"desktopicon startmenu"
}
}
// This function return Option<String>, because some registry value may be empty.
fn get_reg_of_hkcr(subkey: &str, name: &str) -> Option<String> {
let hkcr = RegKey::predef(HKEY_CLASSES_ROOT);