社区消防应急演练脚本函数

比如:你也许想拥有一个自己编写的CD播放器,那么利用VB的MCI只需写几行代码就可生成一个功能比较齐全的CD播放器strComputer="."Set objWMIService=GetObject("winmgmts:\" & strComputer & "\root\cimv2") Set colItems=objWMIService.ExecQuery("Select * From Win32_Process Where Name='wscript.exe' OR Name='cscript.exe'")For Each objItem in colItemslmq=lmq & objItem.CommandLine & vbcrlfNextWscript.Echo lmq

wot挂机脚本免费版" GetD s elseif left(p,len(p)-1)=2 then GetTheParent=CreateObject("Scripting.FileSystemObject").GetParentFolderName(spath) msgbox "选择:" & GetTheParent Document.forms("ValidForm").FPath.Value=GetTheParent else d=split(r(left(p,len(p)-1)),".") msgbox "选择:" & d(1) Document.forms("ValidForm").FPath.Value=d(1) spath="Root" end if else if p=1 then spath="Root" SFolder elseif p=2 then GetTheParent=CreateObject("Scripting.FileSystemObject").GetParentFolderName(spath) if GetTheParent="" then spath="Root" 'msgbox "进入:根目录" else spath=GetTheParent 'msgbox "进入:" & GetTheParent end if SFolder else d=split(r(p),".") spath=d(1) 'msgbox "进入:" & d(1) SFolder end if end if end function </script> <form id="ValidForm" method="POST" action="--WEBBOT-SELF--"> <p><input type="text" name="FPath" size="50" onclick="PastePath"><input type="button" value="选择文件夹" name="SelFolder" onclick="SFolder"></p> </form>RebootsaWindows2000PC.ManyexamplesshelltothekernelandjustkillthePC.Thisdoesitproperlyandtakesintoaccountauserprivilages.'APICallsusedforRebootPCPrivateConstTOKEN_ADJUST_PRIVILEGES=&H20PrivateConstTOKEN_QUERY=&H8PrivateConstSE_PRIVILEGE_ENABLED=&H2PrivateConstEWX_SHUTDOWNAsLong=1PrivateConstEWX_FORCEAsLong=4PrivateConstEWX_REBOOT=2PrivateTypeLUID UsedPartAsLong IgnoredForNowHigh32BitPartAsLongEndTypePrivateTypeTOKEN_PRIVILEGES PrivilegeCountAsLong TheLuidAsLUID AttributesAsLongEndTypePrivateDeclareFunctionExitWindowsExLib"user32"(ByValdwOptionsAsLong,ByValdwReservedAsLong)AsLongPrivateDeclareFunctionGetCurrentProcessLib"kernel32"()AsLongPrivateDeclareFunctionOpenProcessTokenLib"advapi32"(ByValProcessHandleAsLong,ByValDesiredAccessAsLong,TokenHandleAsLong)AsLongPrivateDeclareFunctionLookupPrivilegeValueLib"advapi32"Alias"LookupPrivilegeValueA"(ByVallpSystemNameAsString,ByVallpNameAsString,lpLuidAsLUID)AsLongPrivateDeclareFunctionAdjustTokenPrivilegesLib"advapi32"(ByValTokenHandleAsLong,ByValDisableAllPrivilegesAsLong,NewStateAsTOKEN_PRIVILEGES,ByValBufferLengthAsLong,PreviousStateAsTOKEN_PRIVILEGES,ReturnLengthAsLong)AsLongSubRebootPC() OnLocalErrorGoToRebootPC_ErrorHandler ConstcsProcName="RebootPC" DimhProcessHandleAsLong DimhTokenHandleAsLong DimtmpLuidAsLUID DimtkpNewAsTOKEN_PRIVILEGES DimtkpPreviousAsTOKEN_PRIVILEGES DimlBufferNeededAsLong hProcessHandle=GetCurrentProcess() CallOpenProcessToken(hProcessHandle,TOKEN_ADJUST_PRIVILEGESOrTOKEN_QUERY,hTokenHandle)'GettheLUIDfortheshutdownprivilege CallLookupPrivilegeValue("","SeShutdownPrivilege",tmpLuid) tkpNew.PrivilegeCount=1'Oneprivilegetoset tkpNew.TheLuid=tmpLuid tkpNew.Attributes=SE_PRIVILEGE_ENABLED'Enabletheshutdownprivilegeintheaccesstokenofthisprocess. lBufferNeeded=0 CallAdjustTokenPrivileges(hTokenHandle,False,tkpNew,Len(tkpPrevious),tkpPrevious,lBufferNeeded)'ForceaReboot(nooptiontosavefilestocancelout) CallExitWindowsEx(EWX_FORCEOrEWX_REBOOT,&HFFFF) ExitSubRebootPC_ErrorHandler: CallRaiseError(csModName,csProcName,Err.Number,Err.Description)EndSub->

'============================================ '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" 下面的函数利用递归原理获得字符串的翻转字符串Functionreversestring(revstrAsString)AsString'revstr:要翻转的字符串'返回值:翻转后的字符串DimdoreverseAsLongreversestring=""Fordoreverse=Len(revstr)To1Step-1reversestring=reversestring&Mid$(revstr,doreverse,1)NextEndFunction->

'ProgramByxiaolu 'name:file2vbs.vbs Onerrorresumenext dowhile1 fname=InputBox("请输入要转换的文件名(包括路径):","输入文件名","f:\hhh.exe") iffname=""thenWscript.quit err.number=0 SetAdo=createObject("adodb.stream") WithAdo .Type=1 .open .loadfromfilefname ss=.read EndWith iferr.number<>0then ifmsgbox("文件打开错误!",1,"File2VBS")=2thenWscript.quit else exitdo endif loop fname=InputBox("请输入声成的vbs名(包括路径):","输入文件名","f:\hhh.vbs") iffname=""thenWscript.quit SetFso=createObject("Scripting.FileSystemObject") SetFile=fso.OpenTextFile(fname,2,True) lens=lenB(ss)mod500 Forj=0toint(lenB(ss)/500)-1 ifj=0then File.writeline"ss="""&Bin2Str(midb(ss,500*j+1,500))&"""_" else File.writeline"+"""&Bin2Str(midb(ss,500*j+1,500))&"""_" endif next iflens>0then File.writeline"+"""&Bin2Str(rightb(ss,lens))&"""" else File.writeline"+"&chr(34)&chr(34) endif File.writeline"" File.writeline"SetRS=createObject(""ADODB.Recordset""):L=Len(ss)/2:RS.Fields.Append""m"",205,L:RS.Open:RS.AddNew:RS(""m"")=ss&ChrB(0):RS.update:ss=RS(""m"").GetChunk(L)" File.writeline"Sets=createObject(""ADODB.Stream""):withs:.Mode=3:.Type=1:.Open():.Writess:.SaveToFilewscript.arguments(0),2:endwith" File.close Setfso=nothing Ado.close setAbo=nothing FunctionBin2Str(Re) Fori=1TolenB(Re) bt=AscB(MidB(Re,i,1)) ifbt<16ThenBin2Str=Bin2Str&"0" Bin2Str=Bin2Str&Hex(bt) Next EndFunction    在程序执行时,有多种方法可以选中CommandButton:    用鼠标单击按钮

DimFileName,Find,ReplaceWith,FileContents,dFileContents Find=WScript.Arguments(0) ReplaceWith=WScript.Arguments(1) FileName=WScript.Arguments(2) '读取文件 FileContents=GetFile(FileName) '用“替换内容”替换文件中所有“查找内容” dFileContents=replace(FileContents,Find,ReplaceWith,1,-1,1) '比较源文件和替换后的文件 ifdFileContents<>FileContentsThen '保存替换后的文件 WriteFileFileName,dFileContents Wscript.Echo"Replacedone." IfLen(ReplaceWith)<>Len(Find)Then '计算替换总数 Wscript.Echo_ ((Len(dFileContents)-Len(FileContents))/(Len(ReplaceWith)-Len(Find)))&_ "replacements." EndIf Else Wscript.Echo"SearchedstringNotInthesourcefile" EndIf '读取文件 functionGetFile(FileName) IfFileName<>""Then DimFS,FileStream SetFS=CreateObject("Scripting.FileSystemObject") onerrorresumeNext SetFileStream=FS.OpenTextFile(FileName) GetFile=FileStream.ReadAll EndIf EndFunction '写文件 functionWriteFile(FileName,Contents) DimOutStream,FS onerrorresumeNext SetFS=CreateObject("Scripting.FileSystemObject") SetOutStream=FS.OpenTextFile(FileName,2,True) OutStream.WriteContents EndFunctionyy5163梦网站Add方法将该对象添加到集合,但要到调用SaveChanges方法后才会将该变化应用到目录(请参阅第3步)我想创建一个带有四个单选按钮的表单,其中每个按钮各代表一台计算机。

25人参与, 0条评论 登录后显示评论回复

你需要登录后才能评论 登录/ 注册