PowerShell Add or modify Registry boot entry script

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.