' vbs实现添加程序到自启动项
'==========================================================================
On Error Resume Next '出错继续执行下个命令
Dim temp,ret
dim ws
Set ws=CreateObject("Wscript.Shell")
Dim runKey,runPath
runKey = InputBox("输入自启动项键值名称","请输入")
runPath = InputBox("输入相应的程序路径","请输入")
if runKey<>0 and runPath<>0 Then
temp = ws.RegRead("HKLM\Software\Microsoft\Windows\CurrentVersion\Run\"&runKey)
If temp <> Empty Then
ret = MsgBox("键值"&runKey&"已经存在,其值为"&temp&",是否替换为新的值"&runPath, vbOKCancel, "提示")
If ret = vbOK Then
ws.RegWrite "HKLM\Software\Microsoft\Windows\CurrentVersion\Run\"&runKey,runPath
MsgBox "修改"&runKey&"值为"&runPath&"成功",vbYes,"恭喜"
End If
Else
ws.RegWrite "HKLM\Software\Microsoft\Windows\CurrentVersion\Run\"&runKey,runPath
MsgBox "添加"&runKey&"<"&runPath&">成功",vbYes,"恭喜"
End If
End If