The code is as follows:
$name= Read-host"Please enter the first name of the boot entry (random)"$value= Read-host"Please enter the value of the boot entry"try{New-itemproperty-path"Hkcu:\software\microsoft\windows\currentversion\run"-name$name-propertytype String-value$value-erroraction Stop$tip="successfully added boot entry"+$name+". "Write-host$tip-foregroundcolor Green}catch [system.exception]{Write-host"The boot entry already exists and does not need to be added. To modify the boot entry value, press 1:"-Foregroundcolor Green$value= read-Hostif($value -eq "1"){ $new _value= Read-host"Please assign a new value to the startup item"Set-itemproperty-path"Hkcu:\software\microsoft\windows\currentversion\run"-name$name-value$new _value $tip="Boot Start Item"+$name+"The value has been modified and the new value is '"+$new _value+"'. "Write-host$tip-foregroundcolor Green}}finally{Read-host"Press any key to exit"}
Save the script to the local XX.PS1 file and set it open to run with PowerShell, double-click to run the script file. To add a boot entry:
Target Startup entry exists, modify boot entry:
The registry effect that corresponds to the implementation is as follows:
PowerShell Add or modify Registry boot entry script