'========================================================================== ' ' VBScript Source File -- Created with SAPIEN Technologies PrimalScript 4.1 ' ' NAME: add2run03.vbs ' ' AUTHOR: shile ' DATE : 2008-12-13 ' ' COMMENT: vbs实现添加程序到自启动项 ' '========================================================================== On Error Resume Next '出错继续执行下个命令 dim ws Set ws=CreateObject("Wscript.Shell") Dim runKey,runPath runKey = InputBox("输入自启动项键值名称","请输入") runPath = InputBox("输入相应的程序路径","请输入") Dim temp,ret temp = ws.RegRead("HKLM/Software/Microsoft/Windows/CurrentVersion/Run/"&runKey) 'MsgBox temp 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