Because the editor filters some characters, such as Ampersand, the following script may run incorrectly. Reader add && this character is OK.
The function of the VBS script is many, but sometimes we only need some of these features, today I suddenly want to study how to use the VBS script implementation to add programs to the self starter ...
Let's start with a paragraph ...
Copy Code code as follows:
'==========================================================================
'
' VBScript Source File--Created with SAPIEN Technologies Primalscript 4.1
'
' NAME:add2run01.vbs
'
' Author:shile
' Date:2008-12-13
'
' Comment:vbs implementation add program to self starter
'
'==========================================================================
On Error Resume Next ' error continue with next command
Dim ws
Set ws=createobject ("Wscript.Shell")
Ws. RegWrite "Hklm\software\microsoft\windows\currentversion\run\cmd", "cmd.exe"
has been intercepted by 360 security guards, but click to agree on it. After the autoruns inside refresh still can't show this startup item, it seems this software is not very perfect.
The function is too weak, I want to enhance ....
First, click the window to ask what program to add to the startup item, and ask for the key value of the startup entry.
Copy Code code as follows:
'==========================================================================
'
' VBScript Source File--Created with SAPIEN Technologies Primalscript 4.1
'
' NAME:add2run02.vbs
'
' Author:shile
' Date:2008-12-13
'
' Comment:vbs implementation add program to self starter
'
'==========================================================================
On Error Resume Next ' error continue with next command
Dim ws
Set ws=createobject ("Wscript.Shell")
Dim Runkey,runpath
Runkey = InputBox ("Enter the starting Item key value name", "Please enter")
Runpath = InputBox ("Enter the appropriate program path", "Please enter")
' WS. RegWrite "Hklm\software\microsoft\windows\currentversion\run\cmd", "cmd.exe"
Ws. RegWrite "Hklm\software\microsoft\windows\currentversion\run\" &runkey,runpath
' Hint under
MsgBox "Add" &runkey "<" &runpath "> Success", vbyes, "Congratulations!"
Originally want to use vbOK, but found still two buttons, or vbyes good!
function is still not strong, if you can determine whether there are existing items, whether to replace the confirmation, then more perfect!
Go on ...
Copy Code code as follows:
'==========================================================================
'
' VBScript Source File--Created with SAPIEN Technologies Primalscript 4.1
'
' NAME:add2run03.vbs
'
' Author:shile
' Date:2008-12-13
'
' Comment:vbs implementation add program to self starter
'
'==========================================================================
On Error Resume Next ' error continue with next command
Dim ws
Set ws=createobject ("Wscript.Shell")
Dim Runkey,runpath
Runkey = InputBox ("Enter the starting Item key value name", "Please enter")
Runpath = InputBox ("Enter the appropriate program path", "Please 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 ", replace with the new value" &runpath, vbOKCancel, "Hint!")
IF ret = vbOK Then
Ws. RegWrite "Hklm\software\microsoft\windows\currentversion\run\" &runkey,runpath
MsgBox "Modify" &runkey "value" &runpath "Success", vbyes, "Congratulations!"
End If
Else
Ws. RegWrite "Hklm\software\microsoft\windows\currentversion\run\" &runkey,runpath
MsgBox "Add" &runkey "<" &runpath "> Success", vbyes, "Congratulations!"
End If
Of course, there are many places in the registry for startup items ...