' 脚本说明 https://blog.csdn.net/milaoshu1020/
' 脚本版本 v1.1
' 脚本安装:把脚本文件放到合适的位置,双击安装;
' 脚本使用:在任意文件上点击右键,发送到,启动项.
' [更新历史]
' 2019.01.30 v1.0 初始版本,实现了基本功能.
' 2021.06.12 v1.1 新增修改注册表建制名称的功能;
Set fso = createobject("scripting.filesystemobject")
Set shell = createobject("wscript.shell")
If wscript.arguments.count = 0 Then
Select Case msgbox("是否安装这个""启动项""脚本?",vbokcancel)
Case vbok
sendtodir = shell.specialfolders("SendTo")
lnkpath = fso.buildpath(sendtodir, "启动项.lnk")
Set shortcut = shell.createshortcut(lnkpath)
shortcut.targetpath = wscript.scriptfullname
shortcut.save
msgbox "安装成功!"
End Select
wscript.quit
End If
Const RegPath = "HKCU\Software\Microsoft\Windows\CurrentVersion\Run\"
exepath = wscript.arguments(0)
If LCase(fso.getextensionname(exepath)) = "lnk" Then
Set shortcut = shell.createshortcut(exepath)
exepath = shortcut.targetpath
End If
runname = inputbox("请输入启动项注册表键值名称:","添加启动项",fso.getbasename(exepath))
If runname = "" Then
wscript.quit
End If
Select Case msgbox("选择[是]添加启动项,选择[否]删除启动项,选择[取消]退出.",vbyesnocancel)
Case vbyes
runpath = inputbox("请输入启动项的运行路径及参数:","添加启动项","""" & exepath & """")
If runpath = "" Then
wscript.quit
End If
shell.regwrite regpath & runname,runpath,"REG_SZ"
msgbox "启动项""" & runname & """添加成功!"
Case vbno
On Error Resume Next
Err.clear
temp = shell.regread(regpath & runname)
If Err.number <> 0 Then
msgbox "启动项""" & runname & """不存在!",vbexclamation
wscript.quit
End If
On Error GoTo 0
shell.regdelete(regpath & runname)
msgbox "启动项""" & runname & """删除成功!"
Case vbcancel
wscript.quit
End Select
如何使用VBS脚本管理系统启动项;
最新推荐文章于 2024-05-11 14:37:51 发布