一区二区三区在线-一区二区三区亚洲视频-一区二区三区亚洲-一区二区三区午夜-一区二区三区四区在线视频-一区二区三区四区在线免费观看

腳本之家,腳本語言編程技術及教程分享平臺!
分類導航

Python|VBS|Ruby|Lua|perl|VBA|Golang|PowerShell|Erlang|autoit|Dos|bat|

服務器之家 - 腳本之家 - VBS - vbs 讀寫注冊表之系統啟動項添加與刪除

vbs 讀寫注冊表之系統啟動項添加與刪除

2020-08-20 10:45VBS教程網 VBS

這篇文章主要介紹了vbs 讀寫注冊表之系統啟動項添加值,需要的朋友可以參考下

核心vbs代碼

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
'變量定義
Dim writeName,writeValue,fileName,regLoaction,regApp
 
'創建注冊表編輯器對象
Set regApp=WScript.CreateObject("WScript.Shell")
 
'配置文件名
fileName="FullScan.txt"
'輸入鍵名
writeName="xiaoqiang"
'輸入鍵值
writeValue="test"
 
'************************腳本運行區間********************************
 
'根據配置文件獲取注冊表路徑數組
regLoaction=getRegPathArray(getFileText(fileName))
 
'寫入注冊表
write regLoaction,writeName,writeValue
 
'讀取寫入的鍵值 生成并生成結果文件
read regLoaction,writeName
 
'************************函數定義********************************
'讀注冊表
Function read(regLoaction,writeName)
 Dim returnStrArray(),j
 j=0
 If writeName="" or writeValue="" then
  msgbox "錯誤!!請輸入鍵名和鍵值"
 else
  for i=0 to ubound(regLoaction)
 ReDim Preserve returnStrArray(j)
   regPath=regLoaction(i)&"\"&writeName
   returnStrArray(j)=regPath&"? "&regApp.RegRead(regPath)
   j=j+1
  Next
 End if
 writeResult returnStrArray
End Function
 
'寫入注冊表
Function write(regLoaction,writeName,writeValue)
 If writeName="" or writeValue="" then
  msgbox "錯誤!!請輸入鍵名和鍵值"
 else
  for i=0 to ubound(regLoaction)
 regApp.RegWrite regLoaction(i)&"\"&writeName,writeValue
  Next
 End if
End Function
 
'輸出結果文件
sub writeResult(contentArray)
 Const ForReading = 1, ForWriting = 2
 Dim fso,f,returnStrArray(),i
 Set fso = CreateObject("Scripting.FileSystemObject")
 Set f = fso.OpenTextFile("result.txt", 2,true)
 for i=0 to ubound(contentArray)
 f.writeline(contentArray(i))
 Next
 f.close()
End Sub
 
'得到注冊表路徑數組
Function getRegPathArray(sourceArray)
 Dim head,returnStrArray(),j
 j=0
 for i=0 to ubound(sourceArray)
  If sourceArray(i)="[HKEY_LOCAL_MACHINE]" then
 head="HKLM"
  elseif sourceArray(i)="[HKEY_USERS]" then
   head="HKEY_USERS\.DEFAULT"
  elseif sourceArray(i)="[HKEY_CURRENT_USER]" then
   head="HKCU"
  elseif sourceArray(i)="[HKEY_CLASSES_ROOT]" then
   head="HKCR"
  elseif sourceArray(i)="[HKEY_CURRENT_CONFIG]" then
   head="HKEY_CURRENT_CONFIG"
  else
   ReDim Preserve returnStrArray(j)
   str=head&split(sourceArray(i),"=")(1)
   returnStrArray(j)=str
   j=j+1
  End If
 Next
 getRegPathArray=returnStrArray
End Function
 
'得到文件內容存入數組
Function getFileText(fileName)
 Const ForReading = 1, ForWriting = 2
 Dim fso,f,returnStrArray(),i
 Set fso = CreateObject("Scripting.FileSystemObject")
 Set f = fso.OpenTextFile(fileName, 1)
 i=0
 do while f.atendofstream<>true
  ReDim Preserve returnStrArray(i)
  returnStrArray(i)=f.readline()
  i=i+1
 loop
 f.close()
 getFileText=returnStrArray
End Function

//配置文件

FullScan.txt

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
[HKEY_LOCAL_MACHINE]
1=\Software\Microsoft\Windows\CurrentVersion\Run
2=\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer\Run\
3=\Software\Microsoft\Windows\CurrentVersion\RunOnce\
4=\Software\Microsoft\Windows\CurrentVersion\RunServicesOnce\
5=\Software\Microsoft\Windows\CurrentVersion\RunOnceEx
6=\Software\Microsoft\Windows\CurrentVersion\Policies\System\Shell\
7=\Software\Microsoft\Windows\CurrentVersion\ShellServiceObjectDelayLoad\
8=\Software\Policies\Microsoft\Windows\System\Scripts\
[HKEY_CURRENT_USER]
1=\Software\Microsoft\Windows\CurrentVersion\Run
2=\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer\Run\
3=\Software\Microsoft\Windows\CurrentVersion\RunOnce\
4=\Software\Microsoft\Windows\CurrentVersion\RunServicesOnce\
5=\Software\Microsoft\Windows\CurrentVersion\RunOnceEx
6=\Software\Microsoft\Windows\CurrentVersion\Policies\System\Shell\
7=\Software\Microsoft\Windows\CurrentVersion\ShellServiceObjectDelayLoad\
8=\Software\Policies\Microsoft\Windows\System\Scripts\

運行后得到result.txt

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
HKLM\Software\Microsoft\Windows\CurrentVersion\Run\xiaoqiang? test
HKLM\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer\Run\\xiaoqiang? test
HKLM\Software\Microsoft\Windows\CurrentVersion\RunOnce\\xiaoqiang? test
HKLM\Software\Microsoft\Windows\CurrentVersion\RunServicesOnce\\xiaoqiang? test
HKLM\Software\Microsoft\Windows\CurrentVersion\RunOnceEx\xiaoqiang? test
HKLM\Software\Microsoft\Windows\CurrentVersion\Policies\System\Shell\\xiaoqiang? test
HKLM\Software\Microsoft\Windows\CurrentVersion\ShellServiceObjectDelayLoad\\xiaoqiang? test
HKLM\Software\Policies\Microsoft\Windows\System\Scripts\\xiaoqiang? test
HKCU\Software\Microsoft\Windows\CurrentVersion\Run\xiaoqiang? test
HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer\Run\\xiaoqiang? test
HKCU\Software\Microsoft\Windows\CurrentVersion\RunOnce\\xiaoqiang? test
HKCU\Software\Microsoft\Windows\CurrentVersion\RunServicesOnce\\xiaoqiang? test
HKCU\Software\Microsoft\Windows\CurrentVersion\RunOnceEx\xiaoqiang? test
HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\System\Shell\\xiaoqiang? test
HKCU\Software\Microsoft\Windows\CurrentVersion\ShellServiceObjectDelayLoad\\xiaoqiang? test
HKCU\Software\Policies\Microsoft\Windows\System\Scripts\\xiaoqiang? test

注冊表中的值

vbs 讀寫注冊表之系統啟動項添加與刪除

以下是服務器之家小編補充

運行后就會發現在系統開始自動運行的一些啟動項加入了如上值,所以不建議普通用戶運行。

既然批量添加那么也可以批量刪除

將上面的vbs代碼中的

regApp.RegWrite regLoaction(i)&"\"&writeName,writeValue

替換為

regApp.RegDelete regLoaction(i)&"\"&writeName

發現直接運行不行,其實注冊表的刪除需要用管理員權限才可以。

怕有些新手不知道如何管理員權限運行vbs

其實右鍵cmd中看到 以管理員權限運行 打開 dos窗口,然后將vbs文件拖到這個dos窗口里面,回車運行即可

vbs 讀寫注冊表之系統啟動項添加與刪除

然后拖拉

vbs 讀寫注冊表之系統啟動項添加與刪除

回車后發現,并沒有提示任何錯誤信息,從注冊表中看到,確定這個字段已經沒了。完全解決。

延伸 · 閱讀

精彩推薦
主站蜘蛛池模板: 性导航h | 美女靠逼动漫 | 波多野结衣在线看 | av中文字幕网免费观看 | 91制片在线观看 | 亚洲色图网址 | 二次元美女挤奶漫画 | 久久国产视频网 | 暖暖的韩国免费观看 | 国产色站| 日产免费自线一二区 | 欧美久久一区二区三区 | 亚洲国产精品网 | 韩国三级在线观看 完整版 韩国三级视频网站 | 免费高清视频免费观看 | 国产精品视频第一区二区三区 | 奶茶视频有容乃大 | 国产一卡2卡3卡四卡高清 | 五月天在线视频观看 | 欧美影院一区二区三区 | 秋霞一级毛片 | 2014天堂| 男人与雌性宠物交啪啪小说 | 国产高清ujzzujzz | 国内揄拍国内精品久久 | 884hutv四虎永久7777 | 香蕉久久夜色精品国产尤物 | 石原莉奈被店长侵犯免费 | 国产午夜免费不卡精品理论片 | 欧美一级视频在线观看 | 波多野结衣两女调教 | 日本大学jalapsikix | 亚洲日本视频在线观看 | 性做久久久久久久久浪潮 | zol中关村在线官网 yy6080欧美三级理论 | 美女的让男人桶爽免费看 | 日本不卡免费新一二三区 | 久久视频这只精品99re6 | 精品国产欧美精品v | 我的奶头被客人吸的又肿又红 | 亚洲欧美精品一区天堂久久 |