本来要用vbOK的,但是发现还是两个按钮,还是vbYes好! 功能还是不太强的,如果能判断是否存在已经有的项,是否替换确认,那么就比较完善了! 继续下去... 复制代码 代码如下: "========================================================================== " " 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("HKLMSoftwareMicrosoftWindowsCurrentVersionRun"&runKey) "MsgBox temp If temp <> Empty Then ret = MsgBox( "键值"&runKey"已经存在,其值为"&temp",是否替换为新的值"&runPath, vbOKCancel, "提示!") If ret = vbOK Then ws.RegWrite "HKLMSoftwareMicrosoftWindowsCurrentVersionRun"&runKey,runPath MsgBox "修改"&runKey"值为"&runPath"成功",vbYes,"恭喜!" End If Else ws.RegWrite "HKLMSoftwareMicrosoftWindowsCurrentVersionRun"&runKey,runPath MsgBox "添加"&runKey"<"&runPath">成功",vbYes,"恭喜!" End If