VBS加密解密源码(UserAccounts.CommonDialog) 脚本之家修正版
程序员文章站
2022-07-04 20:41:46
用法: 1.copy下面代码至文本文档 2.将文件后缀名改为.vbs 3.双击运行 复制代码 代码如下: ans = inputbox("请输入要执行的操作:1.加密,2....
用法:
1.copy下面代码至文本文档
2.将文件后缀名改为.vbs
3.双击运行
ans = inputbox("请输入要执行的操作:1.加密,2.解密,3.退出。")
ans = int(ans)
if ans =1 then
set fso=createobject("scripting.filesystemobject")
set objdialog = createobject("useraccounts.commondialog")
objdialog.filter = "vbs file|*.vbs|all files|*.*"
objdialog.initialdir = ""
objdialog.showopen
strloadfile = objdialog.filename
if not strloadfile = "" then
set op=fso.opentextfile(strloadfile)
dow=13
do while op.atendofstream=false
line=op.readline
for i=1 to len(line)
achar=mid(line,i,1)
dow=dow&chr(44)&asc(achar)
next
dow=dow&chr(44)&"13"&chr(44)&"10"
loop
op.close
set op=fso.opentextfile(strloadfile,2)
op.write "strs=array("&dow&")"&chr(13)&chr(10)&_
"for i=1 to ubound(strs)"&chr(13)&chr(10)&_
" runner=runner&chr(strs(i))"&chr(13)&chr(10)&_
"next"&chr(13)&chr(10)&_
"execute runner"
msgbox "加密成功",,"提示"
end if
end if
if ans = 2 then
set objfs=createobject("scripting.filesystemobject")
set objdialog=createobject("useraccounts.commondialog")
objdialog.filter="vbs file|*.vbs|all files|*.*"
objdialog.initialdir = ""
objdialog.showopen
strloadfile = objdialog.filename
if not strloadfile = "" then
set objf=objfs.opentextfile(strloadfile)
str=objf.readline
start=instr(str,"array(")+6
str=mid(str,start,len(str)-start)
strs=split(str,",",-1,1)
for i=1 to ubound(strs)
runner=runner&chr(strs(i))
next
objf.close
set objf=objfs.opentextfile(strloadfile,2)
objf.write runner
msgbox "解密成功",,"提示"
end if
end if
if ans = 3 then
wscript.quit
end if
注意上面的代码只有在winxp下使用,原因可以参考因为那个选择文件功能不能使用而已,下面我们修改下,让他支持win2000,win2003系统,我们可以通过拖动文件到这个vbs上即可。
修改的加强版本
if wscript.arguments.count=0 then wscript.quit
strloadfile=wscript.arguments(0)
ans = inputbox("请输入要执行的操作:1.加密,2.解密,3.退出。")
ans = int(ans)
if ans =1 then
set fso=createobject("scripting.filesystemobject")
if not strloadfile = "" then
set op=fso.opentextfile(strloadfile)
dow=13
do while op.atendofstream=false
line=op.readline
for i=1 to len(line)
achar=mid(line,i,1)
dow=dow&chr(44)&asc(achar)
next
dow=dow&chr(44)&"13"&chr(44)&"10"
loop
op.close
set op=fso.opentextfile(strloadfile,2)
op.write "strs=array("&dow&")"&chr(13)&chr(10)&_
"for i=1 to ubound(strs)"&chr(13)&chr(10)&_
" runner=runner&chr(strs(i))"&chr(13)&chr(10)&_
"next"&chr(13)&chr(10)&_
"execute runner"
msgbox "加密成功",,"提示"
end if
end if
if ans = 2 then
set objfs=createobject("scripting.filesystemobject")
if not strloadfile = "" then
set objf=objfs.opentextfile(strloadfile)
str=objf.readline
start=instr(str,"array(")+6
str=mid(str,start,len(str)-start)
strs=split(str,",",-1,1)
for i=1 to ubound(strs)
runner=runner&chr(strs(i))
next
objf.close
set objf=objfs.opentextfile(strloadfile,2)
objf.write runner
msgbox "解密成功",,"提示"
end if
end if
if ans = 3 then
wscript.quit
end if
1.copy下面代码至文本文档
2.将文件后缀名改为.vbs
3.双击运行
复制代码 代码如下:
ans = inputbox("请输入要执行的操作:1.加密,2.解密,3.退出。")
ans = int(ans)
if ans =1 then
set fso=createobject("scripting.filesystemobject")
set objdialog = createobject("useraccounts.commondialog")
objdialog.filter = "vbs file|*.vbs|all files|*.*"
objdialog.initialdir = ""
objdialog.showopen
strloadfile = objdialog.filename
if not strloadfile = "" then
set op=fso.opentextfile(strloadfile)
dow=13
do while op.atendofstream=false
line=op.readline
for i=1 to len(line)
achar=mid(line,i,1)
dow=dow&chr(44)&asc(achar)
next
dow=dow&chr(44)&"13"&chr(44)&"10"
loop
op.close
set op=fso.opentextfile(strloadfile,2)
op.write "strs=array("&dow&")"&chr(13)&chr(10)&_
"for i=1 to ubound(strs)"&chr(13)&chr(10)&_
" runner=runner&chr(strs(i))"&chr(13)&chr(10)&_
"next"&chr(13)&chr(10)&_
"execute runner"
msgbox "加密成功",,"提示"
end if
end if
if ans = 2 then
set objfs=createobject("scripting.filesystemobject")
set objdialog=createobject("useraccounts.commondialog")
objdialog.filter="vbs file|*.vbs|all files|*.*"
objdialog.initialdir = ""
objdialog.showopen
strloadfile = objdialog.filename
if not strloadfile = "" then
set objf=objfs.opentextfile(strloadfile)
str=objf.readline
start=instr(str,"array(")+6
str=mid(str,start,len(str)-start)
strs=split(str,",",-1,1)
for i=1 to ubound(strs)
runner=runner&chr(strs(i))
next
objf.close
set objf=objfs.opentextfile(strloadfile,2)
objf.write runner
msgbox "解密成功",,"提示"
end if
end if
if ans = 3 then
wscript.quit
end if
注意上面的代码只有在winxp下使用,原因可以参考因为那个选择文件功能不能使用而已,下面我们修改下,让他支持win2000,win2003系统,我们可以通过拖动文件到这个vbs上即可。
修改的加强版本
复制代码 代码如下:
if wscript.arguments.count=0 then wscript.quit
strloadfile=wscript.arguments(0)
ans = inputbox("请输入要执行的操作:1.加密,2.解密,3.退出。")
ans = int(ans)
if ans =1 then
set fso=createobject("scripting.filesystemobject")
if not strloadfile = "" then
set op=fso.opentextfile(strloadfile)
dow=13
do while op.atendofstream=false
line=op.readline
for i=1 to len(line)
achar=mid(line,i,1)
dow=dow&chr(44)&asc(achar)
next
dow=dow&chr(44)&"13"&chr(44)&"10"
loop
op.close
set op=fso.opentextfile(strloadfile,2)
op.write "strs=array("&dow&")"&chr(13)&chr(10)&_
"for i=1 to ubound(strs)"&chr(13)&chr(10)&_
" runner=runner&chr(strs(i))"&chr(13)&chr(10)&_
"next"&chr(13)&chr(10)&_
"execute runner"
msgbox "加密成功",,"提示"
end if
end if
if ans = 2 then
set objfs=createobject("scripting.filesystemobject")
if not strloadfile = "" then
set objf=objfs.opentextfile(strloadfile)
str=objf.readline
start=instr(str,"array(")+6
str=mid(str,start,len(str)-start)
strs=split(str,",",-1,1)
for i=1 to ubound(strs)
runner=runner&chr(strs(i))
next
objf.close
set objf=objfs.opentextfile(strloadfile,2)
objf.write runner
msgbox "解密成功",,"提示"
end if
end if
if ans = 3 then
wscript.quit
end if