Use the vbs script to add the code from the program to the startup Item

Source: Internet
Author: User

Because the Editor filters some characters, such as &, the following script may run incorrectly .. Add & this character to the viewer.
There are many vbs script functions, but sometimes we only need some of them, today, I suddenly want to study how to use the vbs script to add a program to a self-starting item ......

Let's start with a paragraph...

Copy codeThe Code is as follows: '================================================ ==========================================
'
'Vbscript Source File -- Created with SAPIEN Technologies PrimalScript 4.1
'
'Name: add2run01. vbs
'
'Author: shile
'Date: 2008-12-13
'
'Comment: vbs implements adding a program to a self-starting item
'
'================================================ ==========================================
On Error Resume Next 'Error continues executing Next command
Dim ws
Set ws = CreateObject ("Wscript. Shell ")
Ws. RegWrite "HKLM \ Software \ Microsoft \ Windows \ CurrentVersion \ Run \ cmd", "cmd.exe"

It was intercepted by the 360 security guard, but you can click "agree. The startup item cannot be displayed after being refreshed in autoruns. It seems that this software is not perfect.
The function is too weak. I want to enhance it ....
First, open a window to ask what program to add to the startup item, and ask about the key value of the startup Item.Copy codeThe Code is as follows: '================================================ ==========================================
'
'Vbscript Source File -- Created with SAPIEN Technologies PrimalScript 4.1
'
'Name: add2run02. vbs
'
'Author: shile
'Date: 2008-12-13
'
'Comment: vbs implements adding a program to a self-starting item
'
'================================================ ==========================================
On Error Resume Next 'Error continues executing Next command
Dim ws
Set ws = CreateObject ("Wscript. Shell ")
Dim runKey, runPath
RunKey = InputBox ("enter the name of the auto-START key value", "enter ")
RunPath = InputBox ("Enter the corresponding program path", "enter ")

'Ws. RegWrite "HKLM \ Software \ Microsoft \ Windows \ CurrentVersion \ Run \ cmd", "cmd.exe"
Ws. RegWrite "HKLM \ Software \ Microsoft \ Windows \ CurrentVersion \ Run \" & runKey, runPath
'Prompt
MsgBox "added" & runKey "<" & runPath "> succeeded", vbYes, "Congratulations! "

It was originally intended to use vbOK, but we found that there are still two buttons, or vbYes!
The function is still not strong. If you can determine whether there are existing items and whether to replace the items for confirmation, it will be more complete!
Continue...Copy codeThe Code is as follows: '================================================ ==========================================
'
'Vbscript Source File -- Created with SAPIEN Technologies PrimalScript 4.1
'
'Name: add2run03. vbs
'
'Author: shile
'Date: 2008-12-13
'
'Comment: vbs implements adding a program to a self-starting item
'
'================================================ ==========================================
On Error Resume Next 'Error continues executing Next command
Dim ws
Set ws = CreateObject ("Wscript. Shell ")
Dim runKey, runPath
RunKey = InputBox ("enter the name of the auto-START key value", "enter ")
RunPath = InputBox ("Enter the corresponding program path", "enter ")
Dim temp, ret
Temp = ws. RegRead ("HKLM \ Software \ Microsoft \ Windows \ CurrentVersion \ Run \" & runKey)
'Msgbox temp
If temp <> Empty Then
Ret = MsgBox ("key value" & runKey "already exists, its value is" & temp ", whether to replace it with a new value" & runPath, vbOKCancel, "prompt! ")
If ret = vbOK Then
Ws. RegWrite "HKLM \ Software \ Microsoft \ Windows \ CurrentVersion \ Run \" & runKey, runPath
MsgBox "changed" & runKey "to" & runPath "success", vbYes, "Congratulations! "
End If
Else
Ws. RegWrite "HKLM \ Software \ Microsoft \ Windows \ CurrentVersion \ Run \" & runKey, runPath
MsgBox "added" & runKey "<" & runPath "> succeeded", vbYes, "Congratulations! "
End If

Of course, there are many boot items in the registry ......

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.