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 ......