vbs 指令碼程式設計之修改登錄檔
從登錄檔中返回項值或值名。set vbsregread = createobject("wscript.shell")
temp = vbsregread.regread("hklm\software\microsoft\windows\currentversion\run\hotkeyscmds")
wscript.echo temp
object引數.regread(strname
)
object
wshshell 物件。
strname
表示所需的項名或值名的字串值。 說明
regread 方法返回以下五種型別的值。 型別
說明形式
reg_sz
字串字串
reg_dword
數字整數
reg_binary
二進位制值
由整數組成的 vb 陣列
reg_expand_sz
可擴充套件的字串(例如,"%windir%\\calc.exe")
字串reg_multi_sz
字串陣列
由字串組成的 vb 陣列
可通過用最後的反斜線終止 strname 來指定項名。指定值名時最後不要包括反斜線。值由三部分組成:名稱、資料型別和值。指定項名(與值名相反)時,regread 返回預設值。要讀取項的預設值,請指定項本身的名稱。完全限定的項名和值名以根項開頭。可以將縮寫版本的根項名稱用於 regread 方法。下表列出了五個可能的根項。
根項名縮寫hkey_current_user
hkcu
hkey_local_machine
hklm
hkey_classes_root
hkcr
hkey_users
hkey_users
hkey_current_config
hkey_current_config
2、寫登錄檔
如果在使用regwrite時使用了括號,則會出現「microsoft vbscript 編譯器錯誤: 呼叫過程(sub)時不能使用括號」,不寫明data types時,預設是reg_sz型別set vbsregwrite = createobject("wscript.shell")
dim path
path = "hklm\software\microsoft\windows\currentversion\run\"
vbsregwrite.regwrite path & "test","testregwrite","reg_sz"
反斜槓結尾
3、刪除關鍵字和值path="hkey_local_machine\software\microsoft\windows\currentversion\run\sssa2000\love\"
set ws=wscript.createobject("wscript.shell")
val=ws.regwrite(path,"nenboy")
val=ws.regread(path)
wscript.echo val
在上面的基礎上,加以下**即可
vbsregwrite.regdelete path & "test"
vbs幫助文件上的例子:
dim wshshell, bkey
set wshshell = wscript.createobject("wscript.shell")
wshshell. regwrite"hkcu\software\acme\fortuneteller\", 1, "reg_binary"
wshshell. regwrite"hkcu\software\acme\fortuneteller\mindreader", "goocher!", "reg_sz"
bkey = wshshell.regread("hkcu\software\acme\fortuneteller\")
wscript.echo wshshell.regread("hkcu\software\acme\fortuneteller\mindreader")
wshshell.regdelete "hkcu\software\acme\fortuneteller\mindreader"
wshshell.regdelete "hkcu\software\acme\fortuneteller\"
wshshell.regdelete "hkcu\software\acme\"
vbs 讀寫登錄檔
vbs 配置檔名 filename fullscan.txt 輸入鍵名 writename xiaoqiang 輸入鍵值 writevalue test 指令碼執行區間 根據配置檔案獲取登錄檔路徑陣列 regloaction getregpatharray getfiletext filename ...
登錄檔操作
近來由於需要在自己寫的程式中對登錄檔進行操作。總結些經驗,並做個乙個demo供日後使用,現在把它拿出來和大家分享 小弟初學vc,有誤之處還請賜教。為了使用方便,我把一些操作寫成了函式,以便方便呼叫,具體 如下所示 一 定義 hkey hkey char content 256 所查詢登錄檔鍵值的內容...
登錄檔操作
2005年10月29日 19 29 00 一 寫入 1.建立檔案 建立乙個註冊 式檔案 reg,內容如下 windows registry editor version 5.00 hkey local machine software test server 192.168.66.22 databa...