reg2vbs.vbs 将Reg文件转换为VBS文件保存 脚本之家修正版本
程序员文章站
2022-03-21 11:03:01
复制代码 代码如下:'***************************************************************************...
复制代码 代码如下:
'*****************************************************************************
' filename: reg2vbs.vbs
' author: baomaboy
' abstract: 将reg文件转换为vbs文件保存
'*****************************************************************************
dim wshshell,fso
on error resume next
set wshshell = wscript.createobject("wscript.shell")
set fso = createobject("scripting.filesystemobject")
set args = wscript.arguments
closetime = 5
filename = wscript.scriptname
filefullname = wscript.scriptfullname
filepath = fso.getparentfoldername(filefullname)
inspath = fso.getspecialfolder(1)
insfullname = fso.buildpath(inspath ,filename)
copyright="玲珑科技"
qq="qq:25926183"
email="email:[email=25926183@qq.com]25926183@qq.com[/email]"
institle="reg2vbs-txt"
insanswer="reg2vbs-txt"
regpath1="hkey_classes_root\regfile\shell\regtovbs\"
regvalue1="reg转vbs脚本文件"
regform1="reg_sz"
regpath2="hkey_classes_root\regfile\shell\regtovbs\command\"
regvalue2="wscript.exe """& insfullname &""" ""%l"""
regform2="reg_sz"
if filefullname <> insfullname then
intanswer = msgbox("【是】将“"+ insanswer +"”加入到右键菜单,"&chr(10)&chr(10)&"【否】将“"+ insanswer +"”从右键菜单删除。 ", vbquestion + vbyesnocancel, "安装 - "+ institle +" - by baomaboy")
if intanswer = vbyes then
wshshell.regwrite regpath1,regvalue1,regform1
wshshell.regwrite regpath2,regvalue2,regform2
fso.getfile(filefullname).copy(insfullname)
wshshell.popup _
"添加脚本文件:"+chr(10)+insfullname+chr(10)+chr(10)+ _
"添加注册表项:"+chr(10)+chr(34)+ regpath1 +chr(34)+chr(10)+ _
chr(10) & closetime & " 秒钟后本窗口将自动关闭!" +chr(10)+chr(10)+ _
chr(10) & "copyright(c) " + copyright +" " & qq &" " + email _
, closetime, "安装成功 - "+ institle +" - by baomaboy", 0 + 64
end if
if intanswer = vbno then
wshshell.regdelete regpath2
wshshell.regdelete regpath1
fso.deletefile insfullname
wshshell.popup _
"删除脚本文件:"+chr(10)+insfullname+chr(10)+chr(10)+ _
"删除注册表项:"+chr(10)+chr(34)+ regpath1 +chr(34)+chr(10)+ _
chr(10) & closetime & " 秒钟后本窗口将自动关闭!" +chr(10)+chr(10)+ _
chr(10) & "copyright(c) " + copyright +" " & qq &" " + email _
, closetime, "卸载成功 - "+ institle +" - by baomaboy", 0 + 64
end if
if intanswer = vbcancel then
end if
else
if args.count=0 then wscript.quit
set readfile = fso.opentextfile(args(0), 1,false,-1)
readalltext = readfile.readall
readfile.close
if mid(readalltext,1,3) <> "win" and mid(readalltext,1,3) <> "reg" then
set readfile = fso.opentextfile(args(0), 1)
readalltext = readfile.readall
readfile.close
end if
for i=1 to len(readalltext)
tempnum = asc(mid(readalltext,i,1))
if tempnum = 34 then
tempnum = 18
elseif tempnum = 13 then
tempnum = 28
elseif tempnum = 10 then
tempnum = 29
end if
thistext1 = thistext1 & chr(tempnum)
next
set writefile = fso.opentextfile(args(0)&".vbs",2,true)
writefile.writeline("on error resume next : dim wshshell,fso,reg2vbs:set wshshell = wscript.createobject(""wscript.shell""):set fso = createobject(""scripting.filesystemobject""):reg2vbs="""& thistext1 &"""")
writefile.writeline("execute(""for i=1 to len(reg2vbs)""&vbcrlf&""tempnum = asc(mid(reg2vbs,i,1))""&vbcrlf&""if tempnum = 28 then""&vbcrlf&""tempnum = 13""&vbcrlf&""elseif tempnum = 29 then""&vbcrlf&""tempnum = 10""&vbcrlf&""elseif tempnum=18 then""&vbcrlf&""tempnum = 34""&vbcrlf&""end if""&vbcrlf&""thistext2 = thistext2 & chr(tempnum)""&vbcrlf&""next"")")
writefile.writeline("set regfile = fso.opentextfile(fso.buildpath(fso.getspecialfolder(2),""temp.reg""),2,true):regfile.writeline(thistext2):regfile.close:wshshell.run(""regedit /s ""&fso.buildpath(fso.getspecialfolder(2),""temp.reg"")):wscript.sleep 500:fso.deletefile fso.buildpath(fso.getspecialfolder(2),""temp.reg"")")
writefile.close
end if
set wshshell = nothing
set fso = nothing
set args = nothing
wscript.quit(0)
上一篇: 设置matplotlib 支持中文显示