@@ -282,15 +282,17 @@ pub fn do_remove_from_path() -> Result<()> {
282
282
_apply_new_path ( new_path)
283
283
}
284
284
285
+ const RUSTUP_UNINSTALL_ENTRY : & str = r"Software\Microsoft\Windows\CurrentVersion\Uninstall\Rustup" ;
286
+
285
287
pub fn do_add_to_programs ( ) -> Result < ( ) > {
286
288
use std:: path:: PathBuf ;
287
289
288
290
let key = RegKey :: predef ( HKEY_CURRENT_USER )
289
- . create_subkey ( r"Software\Microsoft\Windows\CurrentVersion\Uninstall\rustup" )
291
+ . create_subkey ( RUSTUP_UNINSTALL_ENTRY )
290
292
. chain_err ( || ErrorKind :: PermissionDenied ) ?
291
293
. 0 ;
292
294
293
- // Don't overwrite registry if rustup is already installed
295
+ // Don't overwrite registry if Rustup is already installed
294
296
let prev = key
295
297
. get_raw_value ( "UninstallString" )
296
298
. map ( |val| from_winreg_value ( & val) ) ;
@@ -304,8 +306,9 @@ pub fn do_add_to_programs() -> Result<()> {
304
306
305
307
let mut path = utils:: cargo_home ( ) ?;
306
308
path. push ( "bin\r ustup.exe" ) ;
307
- let mut uninstall_cmd = path. into_os_string ( ) ;
308
- uninstall_cmd. push ( " self uninstall" ) ;
309
+ let mut uninstall_cmd = OsString :: from ( "\" " ) ;
310
+ uninstall_cmd. push ( path) ;
311
+ uninstall_cmd. push ( "\" self uninstall" ) ;
309
312
310
313
let reg_value = RegValue {
311
314
bytes : to_winreg_bytes ( uninstall_cmd. encode_wide ( ) . collect ( ) ) ,
@@ -314,41 +317,18 @@ pub fn do_add_to_programs() -> Result<()> {
314
317
315
318
key. set_raw_value ( "UninstallString" , & reg_value)
316
319
. chain_err ( || ErrorKind :: PermissionDenied ) ?;
317
- key. set_value ( "DisplayName" , & "rustup - Rust toolchain manager " )
320
+ key. set_value ( "DisplayName" , & "Rustup: the Rust toolchain installer " )
318
321
. chain_err ( || ErrorKind :: PermissionDenied ) ?;
319
322
320
323
Ok ( ( ) )
321
324
}
322
325
323
326
pub fn do_remove_from_programs ( ) -> Result < ( ) > {
324
- use std:: io;
325
- use std:: path:: PathBuf ;
326
-
327
- let root = RegKey :: predef ( HKEY_CURRENT_USER ) ;
328
-
329
- let key = match root. open_subkey ( r"Software\Microsoft\Windows\CurrentVersion\Uninstall\rustup" )
330
- {
331
- Ok ( key) => key,
332
- Err ( ref e) if e. kind ( ) == io:: ErrorKind :: NotFound => return Ok ( ( ) ) ,
333
- Err ( e) => return Err ( e) . chain_err ( || ErrorKind :: PermissionDenied ) ,
334
- } ;
335
-
336
- // Don't remove uninstall information from another installation
337
- let cur = key
338
- . get_raw_value ( "UninstallString" )
339
- . map ( |val| from_winreg_value ( & val) ) ;
340
- if let Ok ( Some ( s) ) = cur {
341
- let mut reg_path = PathBuf :: from ( OsString :: from_wide ( & s) ) ;
342
- reg_path. pop ( ) ;
343
- let mut path = utils:: cargo_home ( ) ?;
344
- path. push ( "bin" ) ;
345
- if reg_path != path {
346
- return Ok ( ( ) ) ;
347
- }
327
+ match RegKey :: predef ( HKEY_CURRENT_USER ) . delete_subkey_all ( RUSTUP_UNINSTALL_ENTRY ) {
328
+ Ok ( ( ) ) => Ok ( ( ) ) ,
329
+ Err ( ref e) if e. kind ( ) == std:: io:: ErrorKind :: NotFound => Ok ( ( ) ) ,
330
+ Err ( e) => Err ( e) . chain_err ( || ErrorKind :: PermissionDenied ) ,
348
331
}
349
-
350
- root. delete_subkey_all ( r"Software\Microsoft\Windows\CurrentVersion\Uninstall\rustup" )
351
- . chain_err ( || ErrorKind :: PermissionDenied )
352
332
}
353
333
354
334
/// Convert a vector UCS-2 chars to a null-terminated UCS-2 string in bytes
0 commit comments