收藏的比较精典VBS代码.doc_第1页
收藏的比较精典VBS代码.doc_第2页
收藏的比较精典VBS代码.doc_第3页
全文预览已结束

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

收藏的比较精典VBS代码Set fso = Wscript.CreateObject(Scripting.FileSystemObject) 创建文件系统对象,用以处理驱 动器、文件夹和文件 Set WshShell = Wscript.CreateObject(Wscript.Shell) 创建系统Shell对象,用以运行程序等等 if fso.fileexists(D:刀剑Onlinealreadyexist.txt) then 如果找到文件“D:刀剑 Onlinealreadyexist.txt”则 WshShell.Run(D:刀剑Online刀剑Online.exe) 运行“D:刀剑Online刀剑Online.exe” elseif fso.fileexists(gengxinupdatedj.exe) then 否则,如果找到 “gengxinupdatedj.exe”则 WshShell.Run(gengxinupdatedj.exe) 运行“gengxinupdatedj.exe” else WshShell.Run(D:刀剑Online刀剑Online.exe) 否则运行“D:刀剑Online刀剑Online.exe” end if 根据条件执行语句结束 VBS 导入注册表,然后执行文件 dim Wsh Set Wsh = WScript.CreateObject(WScript.Shell) Wsh.RegWrite HKCUSOFTWAREAUDITIONAUTOSTART,0,REG_DWORD Wsh.RegWrite HKCUSOFTWAREAUDITIONPATH,G:网络游戏劲舞团1.5,REG_SZ Wsh.RegWrite HKCUSOFTWAREAUDITIONVERSION,1010,REG_DWORD Wsh.run patcher.exe PING内网 不通就 执行关机 的VBS strIP = 54 被PING的内网机器 Set objShell = CreateObject(WScript.Shell) If Not IsOnline(strIP) Then objShell.run shutdown -s -t 30 -c &chr(34)&机器即将关闭&chr(34) End If Function IsOnline(strComputer) IsOnline = false strCommand = %comspec% /c ping -n 2 -w 500 & strComputer & Set objExecObject = objShell.Exec(strCommand) Do While Not objExecObject.StdOut.AtEndOfStream strText = objExecObject.StdOut.ReadAll() If Instr(strText, Reply) 0 Then IsOnline = true End If Loop End Function 开机脚本VBS用于ARP邦定 Set WshShell = Wscript.CreateObject(Wscript.Shell) WshShell.run arp -s 30-18-e5-33-01,0 WshShell.run arp -s 30-18-e5-33-07,0 运行程序 Dim a Set Wsh = WScript.CreateObject(WScript.Shell) a.Run d:网络游戏大话西游IIxy-2.exe 运行 oshell.run d:softhfhfgame3GameClient.lnk 断开网络连接 strNICName = disable =net pci* Set objShell = CreateObject(Wscript.Shell) strCommand = devcon.exe& strNICName objShell.Run strCommand, 0, False 启动网络连接 strNICName = enable =net pci* Set objShell = CreateObject(Wscript.Shell) strCommand = devcon.exe& strNICName objShell.Run strCommand, 0, False 删除文件的VBS脚本 dim fso Set fso = CreateObject(Scripting.FileSystemObject) fso.CopyFile server共享XXX.lnk,c:目标位置1,true 添加 fso.CopyFile server共享XXX.lnk,c:目标位置2,true 添加 fso.DeleteFile c:目标位置1XXX.lnk ,true 删除 fso.DeleteFile c:目标位置2XXX.lnk ,true 删除 Set FSO=NoThing WScript.quit 无界面自动检测安装iscsi客户端,映射及断开映射vbs脚本 下列代码实现无界面自动检测安装iscsi客户端,自动映射 On Error Resume Next setupfile=iscsi2.0.exe iscsi客户端安装文件路径 serverip=00 iscsi服务器ip Set oshell= CreateObject(WScript.Shell) Set fso = CreateObject(Scripting.FileSystemObject) if not fso.fileexists(oshell.ExpandEnvironmentStrings(%WinDir%)+system32iscsicpl.cpl) then oshell.run setupfile& /q,1 end if oshell.run iscsicli AddTargetPortal &serverip& 3260,0,1 oshell.run iscsicli LoginTarget .ricecake.iscsi:00 T * * * * * * * * * * * * * * * 0,0,1 下例代码实现无界面删除iscsi映射盘 filetmp=c:my.txt On Error Resume Next Set Shell = CreateObject(WScript.Shell) Set fso = Wscript.CreateObject(Scripting.FileSystemObject) shell.run cmd /c iscsicli sessionlist&filetmp,0,1 Const ForReading = 1 Dim fso, theFile, retstring Set fso = CreateObject(Scripting.FileSystemObject) Set theFile = fso.OpenTextFile(filetmp, ForReading) aaa=thefile.readall thefile.close function myreadline() X=instr(1,aaa,vbcrlf,vbTextCompare) myline=mid(aaa,1,x-1) aaa=right(aaa,len(aaa)-x) if len(aaa) =1 then myline =end myreadline=myline end function Do While bbbend bbb=myreadline if bbb end then if bbb then if instr(bbb,Session)0 then temID=mid(bbb,instr(bbb,:)+1,len(bbb)-instr(bbb,:) shell.run iscsicli logouttarget&temID,0 end if end if end if Loop fso.deletefile(filetmp) 删除QQ用户文件强制删除是不行的了,要跳过的话这样: Dim fso, folderspec, f, f1, fc folderspec = f:Program FilesTencentQQ 设置你的QQ文件夹 Dim Re Set Re = New RegExp Re.Pattern = d4,13$ Set fso = CreateObject(scripting.FileSystemObject) Set f = fso.GetFolder(folderspec) Set fc = f.SubFolders For Each f1 in fc If Re.Test() Then On E

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论