Skip to content

self-update: automatically delete saved binary on next Windows startup #5109

Open

Description

@ivandeex

What is your current rclone version (output from rclone version)?

1.54.x with #5080 merged in
(blocks on #5080)

What problem are you are trying to solve?

The self-update command on Windows will save current running binary as rclone.old.exe.
@albertony proposed in #5080 (comment) to transparently command Windows to remove saved binary upon next reboot.

How do you think rclone should be changed to solve that?

As explained in #5080 (comment), the relevant Windows API function is exposed as MoveFileEx with flag MOVEFILE_DELAY_UNTIL_REBOOT, so no direct registry access necessary - if it is easy to call the API from go or there is a library wrapping that function.

Activity

  1. added this to the Soon milestone on Mar 10, 2021
  2. albertony commented on Mar 11, 2021

    @albertony
    Contributor

    Existing code in lib/file/preallocate_windows.go, uses both syscall package and golang.org/x/sys/windows to access Windows API functionality. Looks like required function MoveFileEx and constant MOVEFILE_DELAY_UNTIL_REBOOT are both exposed in x/sys/windows. Syscall and x/sys are overlapping, but syscall is....

    Deprecated: this package is locked down. Callers should use the corresponding package in the golang.org/x/sys repository instead.

    (https://golang.org/pkg/syscall/)

    Edit: Use of MoveFileEx with MOVEFILE_DELAY_UNTIL_REBOOT requires admin privileges:

    This value can be used only if the process is in the context of a user who belongs to the administrators group or the LocalSystem account.

    (https://docs.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-movefileexa)

  3. removed their assignment
    on Mar 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions