常春岛资源网 Design By www.syssdc.com
核心vbs代码
'变量定义
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&""®App.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
[HKEY_LOCAL_MACHINE] 1=\Software\Microsoft\Windows\CurrentVersion\Run 2=\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer\Run3=\Software\Microsoft\Windows\CurrentVersion\RunOnce4=\Software\Microsoft\Windows\CurrentVersion\RunServicesOnce5=\Software\Microsoft\Windows\CurrentVersion\RunOnceEx 6=\Software\Microsoft\Windows\CurrentVersion\Policies\System\Shell7=\Software\Microsoft\Windows\CurrentVersion\ShellServiceObjectDelayLoad8=\Software\Policies\Microsoft\Windows\System\Scripts[HKEY_CURRENT_USER] 1=\Software\Microsoft\Windows\CurrentVersion\Run 2=\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer\Run3=\Software\Microsoft\Windows\CurrentVersion\RunOnce4=\Software\Microsoft\Windows\CurrentVersion\RunServicesOnce5=\Software\Microsoft\Windows\CurrentVersion\RunOnceEx 6=\Software\Microsoft\Windows\CurrentVersion\Policies\System\Shell7=\Software\Microsoft\Windows\CurrentVersion\ShellServiceObjectDelayLoad8=\Software\Policies\Microsoft\Windows\System\Scripts\
运行后得到result.txt
HKLM\Software\Microsoft\Windows\CurrentVersion\Run\xiaoqiang"" src="/UploadFiles/2021-04-08/20191208144557.png">以下是小编补充
运行后就会发现在系统开始自动运行的一些启动项加入了如上值,所以不建议普通用户运行。
既然批量添加那么也可以批量删除
将上面的vbs代码中的
regApp.RegWrite regLoaction(i)&"\"&writeName,writeValue
替换为
regApp.RegDelete regLoaction(i)&"\"&writeName
发现直接运行不行,其实注册表的删除需要用管理员权限才可以。
怕有些新手不知道如何管理员权限运行vbs
其实右键cmd中看到 以管理员权限运行 打开 dos窗口,然后将vbs文件拖到这个dos窗口里面,回车运行即可
然后拖拉
回车后发现,并没有提示任何错误信息,从注册表中看到,确定这个字段已经没了。完全解决。
标签:
vbs读写注册表
常春岛资源网 Design By www.syssdc.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
常春岛资源网 Design By www.syssdc.com
暂无评论...
更新日志
2026年01月09日
2026年01月09日
- 小骆驼-《草原狼2(蓝光CD)》[原抓WAV+CUE]
- 群星《欢迎来到我身边 电影原声专辑》[320K/MP3][105.02MB]
- 群星《欢迎来到我身边 电影原声专辑》[FLAC/分轨][480.9MB]
- 雷婷《梦里蓝天HQⅡ》 2023头版限量编号低速原抓[WAV+CUE][463M]
- 群星《2024好听新歌42》AI调整音效【WAV分轨】
- 王思雨-《思念陪着鸿雁飞》WAV
- 王思雨《喜马拉雅HQ》头版限量编号[WAV+CUE]
- 李健《无时无刻》[WAV+CUE][590M]
- 陈奕迅《酝酿》[WAV分轨][502M]
- 卓依婷《化蝶》2CD[WAV+CUE][1.1G]
- 群星《吉他王(黑胶CD)》[WAV+CUE]
- 齐秦《穿乐(穿越)》[WAV+CUE]
- 发烧珍品《数位CD音响测试-动向效果(九)》【WAV+CUE】
- 邝美云《邝美云精装歌集》[DSF][1.6G]
- 吕方《爱一回伤一回》[WAV+CUE][454M]

