PAGE
PAGE # / 38
VBS脚本常用经典代码收集于 2011年7月2日21:13:37整理
在网上查找资料的时候发现好多经典的 vbs 代码,收集起来也为了以后学 习。
VBS播放音乐
Dimwmp
Setwmp=CreateObject("WMPlayer.OCX")
wmp.openState
wmp.URL二'想象之中.mp3"
DoUntilwmp.playState=1
WScript.Sleep1000
Loop
比较流行的VBS整人脚本(保存为 礼物.VBE”这样就可以通过QQ发送
了)Setshell二CreateObject("WScript.Shell")
shell.run"shutdown-s-t60-c 系统即将关闭 .",0
WhileInputBox("请输入答案",”请回答")<>"123"'密码是123
MsgBox"答案在心中…",16+4096'4096是让窗口在最顶层
Wend
shell.run"shutdown-a",0
MsgBox"恭喜",64
修改桌面背景图片
Sphoto二"d:\1.bmp"'输入你自己的BMP路径
Consthkcu=&h80001
Setwmi=GetObject("winmgmts:
stdregprov")wmi.getstringvaluehkcu,"ControlPanel\Desktop","Wallpaper",Spathwmi. setstringvaluehkcu,"ControlPanel\Desktop","TileWallpaper","0"wmi.setstringvaluehk cu,"ControlPanel\Desktop","WallpaperStyle","2"wmi.setdwordvalue
hkcu,"Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced","Listvi ewShadow",1
Setwmi=Nothing
Setfso=CreateObject("scripting.filesystemobject")
Setfs=fso.Getfile(Sphoto)
backname=
fs.Name=fso.GetFileName(Spath)
fs.Copyfso.GetParentFolderName(Spath)&"\",True
fs.Name=backname
Setfso=Nothing
Setws=CreateObject("wscript.shell")
ws.Run"gpupdate/force",vbhide
ws.Run"RunDll
32.exeUSER
32.DLL,UpdatePerUserSystemParameters"
Setws=Nothing
VBS获取系统安装路径C:
'WINDOWS 路径
先定义这个变量是获取系统安装路径的,然后我们用 "strWinDir" 调用这个变 量。
SetWshShell=WScript.CreateObject("WScript.Shell")
strWinDir=WshShell.ExpandEnvironmentStrings("%WinDir%")
VBS获取C:
\Program Files 路径
SetWshShell=WScript.CreateObject("WScript.Shell")
strPorDir=WshShell.ExpandEnvironmentStrings("%ProgramFiles%")
VBS获取C:
'Program Files'Com mon Files 路径
SetWshShell=WScript.CreateObject("WScript.Shell")
strCommDir=WshShell.ExpandEnvironmentStrings("%CommonProgramFiles%") 给桌面添加网址快捷方式
SetWshShell=WScript.CreateObject("Wscript.Shell")
strDesktop=WshShell.SpecialFolders("Desktop")
百
度.In k")oShellL in k.TargetPath二"http:
oShellLink.Description二百度主页”
给收藏夹添加网址
ConstADMINISTRATIVE_TOOLS=6
SetobjShell=CreateObject("Shell.Application")
SetobjFolder=objShell.Namespace(ADMINISTRATIVE_TO