pub struct LifecycleTask { /* private fields */ }Expand description
Everything needed to render the task.
Implementations§
Source§impl LifecycleTask
impl LifecycleTask
Sourcepub fn new(
identity: LifecycleTaskIdentity,
principal: TaskPrincipal,
wsl_executable: &WslExecutable,
linux_binary: impl Into<String>,
) -> Self
pub fn new( identity: LifecycleTaskIdentity, principal: TaskPrincipal, wsl_executable: &WslExecutable, linux_binary: impl Into<String>, ) -> Self
Builds the task for one distribution and one Windows account.
Sourcepub fn with_recovery_root(self, path: PathBuf) -> Self
pub fn with_recovery_root(self, path: PathBuf) -> Self
Give the hold process the Windows directory used for recovery state.
Sourcepub fn with_windows_supervisor(
self,
supervisor: PathBuf,
child: PathBuf,
) -> Self
pub fn with_windows_supervisor( self, supervisor: PathBuf, child: PathBuf, ) -> Self
Run the keep-alive through a Windows process in the owning user’s session. That process can both hold the guest open and recover a WSL transport which LocalSystem cannot see.
Sourcepub fn identity(&self) -> &LifecycleTaskIdentity
pub fn identity(&self) -> &LifecycleTaskIdentity
Which task this is.
Sourcepub fn principal(&self) -> &TaskPrincipal
pub fn principal(&self) -> &TaskPrincipal
The account it runs as.
Sourcepub fn action_arguments(&self) -> Vec<String>
pub fn action_arguments(&self) -> Vec<String>
The action’s argument vector.
The same shape super::probe::LinuxCommand builds for every other
invocation, which is deliberate: the task starts the distribution the
same way the provisioning transaction does, so there is one thing to
get right rather than two.
Sourcepub fn rendered_arguments(&self) -> String
pub fn rendered_arguments(&self) -> String
The vector, quoted into the single string Task Scheduler stores.
Sourcepub fn definition_stamp(&self) -> String
pub fn definition_stamp(&self) -> String
definition N, fingerprint XXXXXXXXXXXXXXXX: the document revision and
a digest of the program, its arguments and the account, carried in the
description.
§Why a digest rather than the values themselves
schtasks /Query /XML writes to a pipe in the console’s code page, not
in the UTF-16 its own header declares (measured on Windows 11), so a
profile path, an account or a distribution name outside that code page
comes back altered. A comparison of the values would then fail on every
update and send every update back to the /Create that needs
administrator rights. The stamp is ASCII and survives the trip.
Sourcepub fn description(&self) -> String
pub fn description(&self) -> String
The description the document carries.
Sourcepub fn is_registered_as(&self, registered: &RegisteredTask) -> bool
pub fn is_registered_as(&self, registered: &RegisteredTask) -> bool
Whether registered already is this task, so that registering it again
would change nothing.
This is what keeps an update from needing administrator rights: when
the answer is yes, wsl install does not call schtasks /Create at
all, and /Create is the call Windows refuses an ordinary token for a
task that an elevated prompt created.
Compared: ownership, whether it is enabled, the
definition_stamp in its description, and –
when they are ASCII and so survive the export unaltered – the program
and its argument string as well, which also catches an action edited by
hand. A task an operator disabled is not “already this task”:
re-registering it is how wsl install has always repaired that.