To add a program to a _vbs code by using the VBS script

Source: Internet
Author: User
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 ...

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.