因編輯器過濾了一些字符,比如,所以下面的腳本可能會(huì)運(yùn)行錯(cuò)誤。??垂偬砑舆@個(gè)字符就可以了。
vbs腳本的功能呢是很多的,不過有時(shí)候我們只需要其中的某些功能,今天我突然想研究下怎么用vbs腳本實(shí)現(xiàn)添加程序到自啟動(dòng)項(xiàng)......
首先來一段吧...
復(fù)制代碼 代碼如下:
'==========================================================================
'
' VBScript Source File -- Created with SAPIEN Technologies PrimalScript 4.1
'
' NAME: add2run01.vbs
'
' AUTHOR: shile
' DATE : 2008-12-13
'
' COMMENT: vbs實(shí)現(xiàn)添加程序到自啟動(dòng)項(xiàng)
'
'==========================================================================
On Error Resume Next '出錯(cuò)繼續(xù)執(zhí)行下個(gè)命令
dim ws
Set ws=CreateObject("Wscript.Shell")
ws.RegWrite "HKLM\Software\Microsoft\Windows\CurrentVersion\Run\cmd","cmd.exe"
竟然被360安全衛(wèi)士攔截了,不過點(diǎn)擊同意就可以了。在autoruns里面刷新后還是不能顯示這個(gè)啟動(dòng)項(xiàng),看來這軟件不太完美.
功能太弱了,我想增強(qiáng)一下....
首先,彈個(gè)窗口詢問詢問添加什么程序到啟動(dòng)項(xiàng),并且詢問下啟動(dòng)項(xiàng)的鍵值。
復(fù)制代碼 代碼如下:
'==========================================================================
'
' VBScript Source File -- Created with SAPIEN Technologies PrimalScript 4.1
'
' NAME: add2run02.vbs
'
' AUTHOR: shile
' DATE : 2008-12-13
'
' COMMENT: vbs實(shí)現(xiàn)添加程序到自啟動(dòng)項(xiàng)
'
'==========================================================================
On Error Resume Next '出錯(cuò)繼續(xù)執(zhí)行下個(gè)命令
Dim ws
Set ws=CreateObject("Wscript.Shell")
Dim runKey,runPath
runKey = InputBox("輸入自啟動(dòng)項(xiàng)鍵值名稱","請輸入")
runPath = InputBox("輸入相應(yīng)的程序路徑","請輸入")
'ws.RegWrite "HKLM\Software\Microsoft\Windows\CurrentVersion\Run\cmd","cmd.exe"
ws.RegWrite "HKLM\Software\Microsoft\Windows\CurrentVersion\Run\"runKey,runPath
'提示下
MsgBox "添加"runKey""runPath">成功",vbYes,"恭喜!"
本來要用vbOK的,但是發(fā)現(xiàn)還是兩個(gè)按鈕,還是vbYes好!
功能還是不太強(qiáng)的,如果能判斷是否存在已經(jīng)有的項(xiàng),是否替換確認(rèn),那么就比較完善了!
繼續(xù)下去...
復(fù)制代碼 代碼如下:
'==========================================================================
'
' VBScript Source File -- Created with SAPIEN Technologies PrimalScript 4.1
'
' NAME: add2run03.vbs
'
' AUTHOR: shile
' DATE : 2008-12-13
'
' COMMENT: vbs實(shí)現(xiàn)添加程序到自啟動(dòng)項(xiàng)
'
'==========================================================================
On Error Resume Next '出錯(cuò)繼續(xù)執(zhí)行下個(gè)命令
dim ws
Set ws=CreateObject("Wscript.Shell")
Dim runKey,runPath
runKey = InputBox("輸入自啟動(dòng)項(xiàng)鍵值名稱","請輸入")
runPath = InputBox("輸入相應(yīng)的程序路徑","請輸入")
Dim temp,ret
temp = ws.RegRead("HKLM\Software\Microsoft\Windows\CurrentVersion\Run\"runKey)
'MsgBox temp
If temp > Empty Then
ret = MsgBox( "鍵值"runKey"已經(jīng)存在,其值為"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
當(dāng)然了,啟動(dòng)項(xiàng)在注冊表有很多地方,就不一一說明了......