Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to add a program to a self-startup item using the vbs script

2025-01-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article is about how to use vbs scripts to add programs to self-startup items. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.

The following script may run incorrectly because the editor filters some characters, such as &. No, no, no. The viewer can just add the character & &.

Vbs scripts have many functions, but sometimes we only need some of them. Today, I suddenly want to study how to use vbs scripts to add programs to self-starting items.

First of all, let's have a paragraph.

'=

'

'VBScript Source File-- Created with SAPIEN Technologies PrimalScript 4.1

'

'NAME: add2run01.vbs

'

'AUTHOR: shile

DATE: 2008-12-13

'

'COMMENT: the vbs implementation adds a program to the self-startup item

'

'=

On Error Resume Next 'error continue with the next command

Dim ws

Set ws=CreateObject ("Wscript.Shell")

Ws.RegWrite "HKLM\ Software\ Microsoft\ Windows\ CurrentVersion\ Run\ cmd", "cmd.exe"

Unexpectedly, it was intercepted by 360 security guards, but click "yes". After refreshing in autoruns, the startup item still cannot be displayed. It'seems that the software is not perfect.

The function is too weak. I want to enhance it.

First, a pop-up window asks what program to add to the startup item, and asks for the key value of the startup item.

The copy code is as follows:

'=

'

'VBScript Source File-- Created with SAPIEN Technologies PrimalScript 4.1

'

'NAME: add2run02.vbs

'

'AUTHOR: shile

DATE: 2008-12-13

'

'COMMENT: the vbs implementation adds a program to the self-startup item

'

'=

On Error Resume Next 'error continue with the next command

Dim ws

Set ws=CreateObject ("Wscript.Shell")

Dim runKey,runPath

RunKey = InputBox ("enter the name of the key value of the self-startup item", "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

'prompt.

MsgBox "add" & runKey "success", vbYes, "Congratulations!"

Originally to use vbOK, but found that there are still two buttons, it is better to vbYes!

The function is not very strong, if you can judge whether there is an existing item, whether to replace the confirmation, then it will be more perfect!

Go on.

The copy code is as follows:

'=

'

'VBScript Source File-- Created with SAPIEN Technologies PrimalScript 4.1

'

'NAME: add2run03.vbs

'

'AUTHOR: shile

DATE: 2008-12-13

'

'COMMENT: the vbs implementation adds a program to the self-startup item

'

'=

On Error Resume Next 'error continue with the next command

Dim ws

Set ws=CreateObject ("Wscript.Shell")

Dim runKey,runPath

RunKey = InputBox ("enter the name of the key value of the self-startup item", "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 ", whether to replace it with the new value" & runPath, vbOKCancel, "prompt!")

If ret = vbOK Then

Ws.RegWrite "HKLM\ Software\ Microsoft\ Windows\ CurrentVersion\ Run\" & runKey,runPath

MsgBox "modify" & runKey "value is" & runPath "success", vbYes, "Congratulations!"

End If

Else

Ws.RegWrite "HKLM\ Software\ Microsoft\ Windows\ CurrentVersion\ Run\" & runKey,runPath

MsgBox "add" & runKey "success", vbYes, "Congratulations!"

End If

Of course, startup entries are in many places in the registry, so they are not explained one by one.

Thank you for reading! This is the end of this article on "how to use vbs scripts to add programs to startup items". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it out for more people to see!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report