资源描述:
《vbs脚本常用代码大全 2011 整理》由会员上传分享,免费在线阅读,更多相关内容在应用文档-天天文库。
1、VBS脚本常用经典代码收集于2011年7月2日21:13:37整理在网上查找资料的时候发现好多经典的vbs代码,收集起来也为了以后学习。VBS播放音乐DimwmpSetwmp=CreateObject("WMPlayer.OCX")wmp.openStatewmp.URL="想象之中.mp3"DoUntilwmp.playState=1WScript.Sleep1000Loop比较流行的VBS整人脚本(保存为“礼物.VBE”这样就可以通过QQ发送了)Setshell=CreateObject("WScript.She
2、ll")shell.run"shutdown-s-t60-c系统即将关闭.",0WhileInputBox("请输入答案","请回答")<>"123"'密码是123MsgBox"答案在心中...",16+4096'4096是让窗口在最顶层Wendshell.run"shutdown-a",0MsgBox"恭喜",64修改桌面背景图片Sphoto="d:1.bmp"'输入你自己的BMP路径computer="."Consthkcu=&h80000001Setwmi=GetObject("winmgmts:\"&co
3、mputer&"rootdefault:stdregprov")wmi.getstringvaluehkcu,"ControlPanelDesktop","Wallpaper",Spathwmi.setstringvaluehkcu,"ControlPanelDesktop","TileWallpaper","0"wmi.setstringvaluehkcu,"ControlPanelDesktop","WallpaperStyle","2"wmi.setdwordvaluehkcu,"SoftwareM
4、icrosoftWindowsCurrentVersionExplorerAdvanced","ListviewShadow",1Setwmi=NothingSetfso=CreateObject("scripting.filesystemobject")Setfs=fso.Getfile(Sphoto)backname=fs.namefs.Name=fso.GetFileName(Spath)fs.Copyfso.GetParentFolderName(Spath)&"",Truefs.Name=back
5、nameSetfso=NothingSetws=CreateObject("wscript.shell")ws.Run"gpupdate/force",vbhidews.Run"RunDll32.exeUSER32.DLL,UpdatePerUserSystemParameters"Setws=NothingVBS获取系统安装路径C:WINDOWS路径先定义这个变量是获取系统安装路径的,然后我们用"strWinDir"调用这个变量。SetWshShell=WScript.CreateObject("WScript.
6、Shell")strWinDir=WshShell.ExpandEnvironmentStrings("%WinDir%")VBS获取C:ProgramFiles路径SetWshShell=WScript.CreateObject("WScript.Shell")strPorDir=WshShell.ExpandEnvironmentStrings("%ProgramFiles%")VBS获取C:ProgramFilesCommonFiles路径SetWshShell=WScript.CreateObject(
7、"WScript.Shell")strCommDir=WshShell.ExpandEnvironmentStrings("%CommonProgramFiles%")给桌面添加网址快捷方式SetWshShell=WScript.CreateObject("Wscript.Shell")strDesktop=WshShell.SpecialFolders("Desktop")SetoShellLink=WshShell.CreateShortcut(strDesktop&"百度.lnk")oShellLink.Ta
8、rgetPath="http://www.baidu.com/"oShellLink.Description="百度主页"oShellLink.IconLocation="%ProgramFiles%InternetExploreriexplore.exe,0"oShellLink.Save给收藏夹添加网址ConstADMINISTRATI