.VBS腳本,,也就是SCRIPT 腳本文件對(duì)注冊(cè)表進(jìn)行修改,。下面我通過一個(gè)例子自來解釋腳本文件: Windows Script Host Sample Script You have a royalty-free right to use, modify, reproduce and distribute the Sample Application Files (and/or any modified version) in any way you find useful, provided that you agree that Microsoft has no warranty, obligations or liability for any Sample Application Files. ------------------------------------------------------------------------ This sample demonstrates how to write/delete entries in the registry. L_Welcome_MsgBox_Message_Text = "此腳本顯示如何創(chuàng)建和刪除注冊(cè)表項(xiàng)。" L_Welcome_MsgBox_Title_Text = "Windows Scripting Host 范例" Call Welcome() ******************************************************************************** * * Registry related methods. * Dim WSHShell Set WSHShell = WScript.CreateObject("WScript.Shell") WSHShell.Popup "創(chuàng)建項(xiàng) HKCU\MyRegKey 數(shù)值為 Top level key" WSHShell.RegWrite "HKCU\MyRegKey\", "Top level key" WSHShell.Popup "創(chuàng)建項(xiàng) HKCU\MyRegKey\Entry 數(shù)值為 Second level key" WSHShell.RegWrite "HKCU\MyRegKey\Entry\", "Second level key" WSHShell.Popup "將數(shù)值項(xiàng) HKCU\MyRegKey\Value 設(shè)為 REG_SZ 1" WSHShell.RegWrite "HKCU\MyRegKey\Value", 1 WSHShell.Popup "將數(shù)值項(xiàng) HKCU\MyRegKey\Entry 設(shè)為 REG_DWORD 2" WSHShell.RegWrite "HKCU\MyRegKey\Entry", 2, "REG_DWORD" WSHShell.Popup "將數(shù)值項(xiàng) HKCU\MyRegKey\Entry\Value1 設(shè)為 REG_BINARY 3" WSHShell.RegWrite "HKCU\MyRegKey\Entry\Value1", 3, "REG_BINARY" WSHShell.Popup ot;刪除 HKCU\MyRegKey\Entry\Value1 數(shù)值" WSHShell.RegDelete "HKCU\MyRegKey\Entry\Value1" WSHShell.Popup "刪除 HKCU\MyRegKey\Entry 項(xiàng)" WSHShell.RegDelete "HKCU\MyRegKey\Entry\" WSHShell.Popup "刪除 HKCU\MyRegKey 項(xiàng)" WSHShell.RegDelete "HKCU\MyRegKey\" ******************************************************************************** * * Welcome * Sub Welcome() Dim intDoIt intDoIt = MsgBox(L_Welcome_MsgBox_Message_Text, _ vbOKCancel + vbInformation, _ L_Welcome_MsgBox_Title_Text ) If intDoIt = vbCancel Then WScript.Quit End If End Sub 1.在上例中,單引號(hào)后面是注釋. 2. L_Welcome_MsgBox_Message_Text = "此腳本顯示如何創(chuàng)建和刪除注冊(cè)表項(xiàng),。" L_Welcome_MsgBox_Title_Text = "Windows Scripting Host 范例" 這兩句是提示. 3. 用 Set WSHShell = WScript.CreateObject("WScript.Shell"),定義一個(gè)對(duì)象WSHSHELL 為WScript.Shell, 4.WELCOME()是一個(gè)確認(rèn)對(duì)話框. 5. WSHShell.Popup "創(chuàng)建項(xiàng) HKCU\MyRegKey 數(shù)值為 Top level key" 是聲明要修改的注冊(cè)表項(xiàng). WSHShell.RegWrite "HKCU\MyRegKey\", "Top level key" 在HKCU下面創(chuàng)建MYREGKEY子鍵,讀者也可以根據(jù)自己實(shí)際情況修改鍵名,、指定路徑。 6,、REG_SZ為字符串,要用引號(hào)引起來,REG_DWORD 為0—2147483647之間整數(shù),REG_BINARY與之范圍相同,。 7、需要注意的是,,若結(jié)尾是“\”則創(chuàng)建一個(gè)主鍵(項(xiàng)),,將其默認(rèn)值設(shè)為逗號(hào)后面的值項(xiàng),若結(jié)尾不是“\”,,則在前一個(gè)“\”后面的項(xiàng)中建立所設(shè)立的VALUE,,逗號(hào)后面為其值。 8,、WSHShell.RegDelete與WSHShell.RegWrite大致相同,,只是功能相反。 各位可以將上面文檔復(fù)制,,存為FILENAME.VBS,,然后雙擊即可。 |
|