VBS脚本文件大全
2011年05月24日
一、自动打开一个网站:
新建一个文本文件, 输入
Set Obj = WScript.CreateObject("WScript.Shell")
Obj.run "iexplore.exe http://www.sina.com",1
另存为xxx.vbs, 主意别存成.vbs.txt了.
现在你双击这个xxx.vbs应该就打开新浪了.
###########################
如何用VBS执行DOS命令
dim obj
set obj=createobject( "cscript.shell ")
obj.run "command /c 命令 "
obj.run "cmd /c 命令 "
###########################
二、自动打开一个文件夹:
新建一个文本文件, 输入
Set Obj = WScript.CreateObject("WScript.Shell")
Obj.run "iexplore.exe D:\file",1
另存为xxx.vbs, 主意别存成.vbs.txt了.
现在你双击这个xxx.vbs应该就打开新浪了.
三、自动映射网络盘:
首先打开记事本,输入
Set WshNetwork = Wscript.CreateObject("Wscript.Network")
Set WshShell = Wscript.CreateObject("Wscript.shell")
wscript.sleep 3000
WshNetwork.MapNetworkDrive "X:","\\FILE\照片资料"
WshNetwork.MapNetworkDrive "Y:","\\FILE\共享文件"
然后保存为logon.vbs,注意扩展名为vbs。
四、QQ自动登录:
set ws=wscript.createobject("wscript.shell")
ws.run "填入你的QQ路径",1
wscript.Sleep 2000
ws.AppActivate "QQ用户登录"
ws.SendKeys "QQ号码"
wscript.Sleep 2000
ws.SendKeys "{TAB}"
ws.SendKeys "密码"
wscript.Sleep 2000
ws.SendKeys "{ENTER}"
五、设置时间自动关机:
set ws=createobject("wscript.shell")
ws.run "at 20:00 shutdown.exe -s -t 0",hide,true
set ws=nothing
如果中途想取消,那就运行下面的vbs
set ws=createobject("wscript.shell")
ws.run "at /delete",hide ,true
set ws=nothing
六、自动清除系统临时文件:
1.清除系统临时文件
Dim fs,f,fc
Const TemporaryFolder=2
On Error Resume Next
Set fs=CreateObject("Scripting.filesystemObject")
Set fs=fs.GetSpecialFolder(2)
Set fc=SubFolders
For Each f In fc
f.Delete True
Next
Set fc=fs.Files
For Each f In fc
f.Delete True
Next
七.清除垃圾自动查找多个盘:
rem made by correy
rem made at 2007.9.22
rem it can be delete you computer's the follow things(except cd,dvd)
rem it can be delete empty file and folder
rem it can be delete .tmp ._mp .log .gid .chk .old file
rem it can be delete temp,recent,cookis,recycled,prefetch,and "Temporary Internet Files" folder.
rem i am thinking how to delete the same size and same name's file and folder
On Error GoTo 0
Set fso = CreateObject("Scripting"&"."&"FileSystem"&"Object")
for n = 1 to 3
For Each d in fso.Drives
if d.drivetype=4 then
Exit For
else
scan(d)
end if
next
next
sub scan(folder)
on error resume next
set folder=fso.getfolder(folder)
for each file in folder.files
if file.size=0 then
file.delete(true)
end if
ext=fso.GetExtensionName(file)
ext=lcase(ext)
if ext="tmp" or ext="_mp" or ext="log" or ext="gid" or ext="chk" or ext="old" then ''30
file.delete(true)
end if
next
for each subfolder in folder.subfolders
rem instrRev() can't be used,i want to find "\".
if left(subfolder.path,4)="temp" or left(subfolder.path,8)="recycled" then
subfolder.delete(true)
elseif left(subfolder.path,6)="recent" or left(subfolder.path,7)="cookies" then
subfolder.delete(true) rem 40
elseif left(subfolder.path,24)="Temporary Internet Files" or left(subfolder.path,8)="prefetch" then
subfolder.delete(true)
end if
if subfolder.size=0 then subfolder.delete(true)
scan(subfolder)
next
end sub
2011年05月24日
一、自动打开一个网站:
新建一个文本文件, 输入
Set Obj = WScript.CreateObject("WScript.Shell")
Obj.run "iexplore.exe http://www.sina.com",1
另存为xxx.vbs, 主意别存成.vbs.txt了.
现在你双击这个xxx.vbs应该就打开新浪了.
###########################
如何用VBS执行DOS命令
dim obj
set obj=createobject( "cscript.shell ")
obj.run "command /c 命令 "
obj.run "cmd /c 命令 "
###########################
二、自动打开一个文件夹:
新建一个文本文件, 输入
Set Obj = WScript.CreateObject("WScript.Shell")
Obj.run "iexplore.exe D:\file",1
另存为xxx.vbs, 主意别存成.vbs.txt了.
现在你双击这个xxx.vbs应该就打开新浪了.
三、自动映射网络盘:
首先打开记事本,输入
Set WshNetwork = Wscript.CreateObject("Wscript.Network")
Set WshShell = Wscript.CreateObject("Wscript.shell")
wscript.sleep 3000
WshNetwork.MapNetworkDrive "X:","\\FILE\照片资料"
WshNetwork.MapNetworkDrive "Y:","\\FILE\共享文件"
然后保存为logon.vbs,注意扩展名为vbs。
四、QQ自动登录:
set ws=wscript.createobject("wscript.shell")
ws.run "填入你的QQ路径",1
wscript.Sleep 2000
ws.AppActivate "QQ用户登录"
ws.SendKeys "QQ号码"
wscript.Sleep 2000
ws.SendKeys "{TAB}"
ws.SendKeys "密码"
wscript.Sleep 2000
ws.SendKeys "{ENTER}"
五、设置时间自动关机:
set ws=createobject("wscript.shell")
ws.run "at 20:00 shutdown.exe -s -t 0",hide,true
set ws=nothing
如果中途想取消,那就运行下面的vbs
set ws=createobject("wscript.shell")
ws.run "at /delete",hide ,true
set ws=nothing
六、自动清除系统临时文件:
1.清除系统临时文件
Dim fs,f,fc
Const TemporaryFolder=2
On Error Resume Next
Set fs=CreateObject("Scripting.filesystemObject")
Set fs=fs.GetSpecialFolder(2)
Set fc=SubFolders
For Each f In fc
f.Delete True
Next
Set fc=fs.Files
For Each f In fc
f.Delete True
Next
七.清除垃圾自动查找多个盘:
rem made by correy
rem made at 2007.9.22
rem it can be delete you computer's the follow things(except cd,dvd)
rem it can be delete empty file and folder
rem it can be delete .tmp ._mp .log .gid .chk .old file
rem it can be delete temp,recent,cookis,recycled,prefetch,and "Temporary Internet Files" folder.
rem i am thinking how to delete the same size and same name's file and folder
On Error GoTo 0
Set fso = CreateObject("Scripting"&"."&"FileSystem"&"Object")
for n = 1 to 3
For Each d in fso.Drives
if d.drivetype=4 then
Exit For
else
scan(d)
end if
next
next
sub scan(folder)
on error resume next
set folder=fso.getfolder(folder)
for each file in folder.files
if file.size=0 then
file.delete(true)
end if
ext=fso.GetExtensionName(file)
ext=lcase(ext)
if ext="tmp" or ext="_mp" or ext="log" or ext="gid" or ext="chk" or ext="old" then ''30
file.delete(true)
end if
next
for each subfolder in folder.subfolders
rem instrRev() can't be used,i want to find "\".
if left(subfolder.path,4)="temp" or left(subfolder.path,8)="recycled" then
subfolder.delete(true)
elseif left(subfolder.path,6)="recent" or left(subfolder.path,7)="cookies" then
subfolder.delete(true) rem 40
elseif left(subfolder.path,24)="Temporary Internet Files" or left(subfolder.path,8)="prefetch" then
subfolder.delete(true)
end if
if subfolder.size=0 then subfolder.delete(true)
scan(subfolder)
next
end sub