File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -269,6 +269,28 @@ pub fn core_main() -> Option<Vec<String>> {
269269 crate :: virtual_display_manager:: amyuni_idd:: uninstall_driver( )
270270 ) ;
271271 return None ;
272+ } else if args[ 0 ] == "--install-remote-printer" {
273+ #[ cfg( windows) ]
274+ if crate :: platform:: is_win_10_or_greater ( ) {
275+ match remote_printer:: install_update_printer ( & crate :: get_app_name ( ) ) {
276+ Ok ( _) => {
277+ log:: info!( "Remote printer installed/updated successfully" ) ;
278+ }
279+ Err ( e) => {
280+ log:: error!( "Failed to install/update the remote printer: {}" , e) ;
281+ }
282+ }
283+ } else {
284+ log:: error!( "Win10 or greater required!" ) ;
285+ }
286+ return None ;
287+ } else if args[ 0 ] == "--uninstall-remote-printer" {
288+ #[ cfg( windows) ]
289+ if crate :: platform:: is_win_10_or_greater ( ) {
290+ remote_printer:: uninstall_printer ( & crate :: get_app_name ( ) ) ;
291+ log:: info!( "Remote printer uninstalled" ) ;
292+ }
293+ return None ;
272294 }
273295 }
274296 #[ cfg( target_os = "macos" ) ]
Original file line number Diff line number Diff line change @@ -1390,6 +1390,16 @@ copy /Y \"{tmp_path}\\{app_name} Tray.lnk\" \"%PROGRAMDATA%\\Microsoft\\Windows\
13901390" )
13911391 } ;
13921392
1393+ let install_remote_printer = if install_printer {
1394+ // No need to use `|| true` here.
1395+ // The script will not exit even if `--install-remote-printer` panics.
1396+ format ! ( "\" {}\" --install-remote-printer" , & src_exe)
1397+ } else if crate :: platform:: is_win_10_or_greater ( ) {
1398+ format ! ( "\" {}\" --uninstall-remote-printer" , & src_exe)
1399+ } else {
1400+ "" . to_owned ( )
1401+ } ;
1402+
13931403 // Remember to check if `update_me` need to be changed if changing the `cmds`.
13941404 // No need to merge the existing dup code, because the code in these two functions are too critical.
13951405 // New code should be written in a common function.
@@ -1418,6 +1428,7 @@ cscript \"{uninstall_shortcut}\"
14181428{tray_shortcuts}
14191429{shortcuts}
14201430copy /Y \" {tmp_path}\\ Uninstall {app_name}.lnk\" \" {path}\\ \"
1431+ {install_remote_printer}
14211432{dels}
14221433{import_config}
14231434{after_install}
@@ -1437,11 +1448,6 @@ copy /Y \"{tmp_path}\\Uninstall {app_name}.lnk\" \"{path}\\\"
14371448 import_config = get_import_config( & exe) ,
14381449 ) ;
14391450 run_cmds ( cmds, debug, "install" ) ?;
1440- if install_printer {
1441- allow_err ! ( remote_printer:: install_update_printer(
1442- & crate :: get_app_name( )
1443- ) ) ;
1444- }
14451451 run_after_run_cmds ( silent) ;
14461452 Ok ( ( ) )
14471453}
You can’t perform that action at this time.
0 commit comments