Problems:
A feature request comes from a member of the 网协电脑诊所线上咨询 group.
Challenges:
- The login attempt may occur before the internet connection is established, leading to potential failures.
- The script requires PowerShell to run as an administrator, which triggers User Account Control (UAC) prompts.
Requirements:
To implement the auto logon process successfully, the following parameters must be known and correctly set:
$executable_path – The full path of the executable that initiates the login process.
$your_executable_parameters – The command-line parameters required for login, for example:
login --username yourUserName --password yourPassword
This ensures the login command runs with the appropriate credentials.
PowerShell Script
$executable_path="path/to/bitsrun"
$your_executable_parameters="login --username yourUserName --password yourPassword"
Register-ScheduledTask -Action (New-ScheduledTaskAction -Execute $executable_path -Argument "your_executable_parameters") -Trigger (New-ScheduledTaskTrigger -AtLogon) -Settings (New-ScheduledTaskSettingsSet -NetworkId "BIT-web" -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries -StartWhenAvailable -MultipleInstances IgnoreNew -DontStopOnIdleEnd -ExecutionTimeLimit 0) -Principal (New-ScheduledTaskPrincipal -UserId $Env:UserName -LogonType Interactive) -TaskName "Bitsrun" -Description "Bitsrun Login At User Logon"
Key Parameters and Their Functions
NetworkId "BIT-web": Ensures the task runs only when connected to the specified network, preventing execution when offline.
AllowStartIfOnBatteries: Enables the task to run even if the device is on battery power, ensuring uninterrupted login.
DontStopIfGoingOnBatteries: Prevents the task from stopping if the power source switches to battery mode.
StartWhenAvailable: If the task fails to execute at the scheduled time (e.g., due to the device being off), it will start as soon as possible when conditions allow.
MultipleInstances IgnoreNew: If the task is already running, additional instances will be ignored to avoid conflicts.
DontStopOnIdleEnd: Ensures that the task continues running even when the system transitions to an idle state.
ExecutionTimeLimit 0: Removes any time limit for the task execution, allowing it to run indefinitely until manually stopped.
This configuration ensures reliable auto logon while minimizing potential interruptions due to system conditions such as power state or network availability.
Problems:
A feature request comes from a member of the
网协电脑诊所线上咨询group.Challenges:
Requirements:
To implement the auto logon process successfully, the following parameters must be known and correctly set:
$executable_path– The full path of the executable that initiates the login process.$your_executable_parameters– The command-line parameters required for login, for example:PowerShell Script
Key Parameters and Their Functions
NetworkId "BIT-web": Ensures the task runs only when connected to the specified network, preventing execution when offline.AllowStartIfOnBatteries: Enables the task to run even if the device is on battery power, ensuring uninterrupted login.DontStopIfGoingOnBatteries: Prevents the task from stopping if the power source switches to battery mode.StartWhenAvailable: If the task fails to execute at the scheduled time (e.g., due to the device being off), it will start as soon as possible when conditions allow.MultipleInstances IgnoreNew: If the task is already running, additional instances will be ignored to avoid conflicts.DontStopOnIdleEnd: Ensures that the task continues running even when the system transitions to an idle state.ExecutionTimeLimit 0: Removes any time limit for the task execution, allowing it to run indefinitely until manually stopped.This configuration ensures reliable auto logon while minimizing potential interruptions due to system conditions such as power state or network availability.