⽤VBS来代替BAT或CMD⽂件进⾏命令⾃动导⼊注册表的,带检测:
On Error Resume Next
dim msg,fso,shell
Set fso = ateobject("scripting.filesystemobject")
set wshshell = wscript.CreateObject("wscript.shell")
set shell = ateobject("wscript.shell")
IF (fso.FileExists("e:\劲乐团\")) Then
shell.run "c:\ /s e:\劲乐团\ "
shell.run "e:\劲乐团\"
Else
msg=msgbox("注册表未导⼊,游戏可能⽆法启动,如⽆法进游戏请叫⽹管~",1,"出问题啦!!") shell.run "e:\劲乐团\"
end if
不带检测的:
On Error Resume Next
Dim oShell,fso
Set oShell = WScript.CreateObject("WScript.Shell")
set fso = CreateObject("Scripting.filesystemobject")
vbs小程序代码大全oShell.Run "regedit /"
oShell.Run "d:\⽹络游戏\劲乐团\"
⾃动加载虚拟光驱的:
Dim oShell
Set oshell= WScript.CreateObject("WScript.Shell")
oShell.Run "c:\progra~1\daemon~ -mount 0,D:\lan\战地2\BF2CD1mini.mds"
wscript.sleep 5000
oShell.Run "D:\lan\战地"
另⼀例⼦:
Dim Wsh,DMpath,ISOpath
DMpath = "X:\" '设置DM路径
ISOpath = "Z:\⼤富翁七\RICH7B.mds" '设置镜像⽂件路径
Set Wsh = WScript.CreateObject("WScript.Shell")
Wsh.run chr(34) & DMpath & chr(34) &" -mount 0,"&ISOpath,0,true
Wscript.Sleep 3000 '最好延时⼏秒等待镜像加载完毕 1000 = 1 秒
Wsh.run "Z:\⼤富翁七\"
Set WSH = Nothing
WScript.quit
//每次开机的时候⾃动导⼊注册表和程序
Option Explicit
Dim Folder
Folder = "d:\aaa" '设置你要执⾏的⽂件夹
Dim Wsh,fso
Set Wsh = WScript.CreateObject("WScript.Shell")
Set fso = CreateObject("Scripting.FileSystemObject")
Dim f,fc,f1,ext
Set f = fso.GetFolder(Folder)
Set fc = f.Files
For Each f1 in fc
ext = LCase(fso.GetExtensionName(f1))
Select Case ext
Case "exe"
wsh.run f1,,true
Case "reg"
wsh.run "Regedit /s "& f1,,true
end Select
Next
Set fso=NoThing
Set Wsh = Nothing
WScript.quit
//排除指定⽂件或⽂件夹删除多余的⽂件或⽂件夹,⿊⽕原创
Option Explicit
''''''''''''''说明''''''''''''
'⽹盟-⿊⽕制作,送给需要的朋友。
'配置⽂件“Listfile.ini”的格式如下:
'要删除什么(⽂件|⽬录)=要执⾏删除的⽂件夹=排除1;排除2;排除3............ '配置⽂件可以有多⾏,以便对多个⽬录进⾏操作。
'配置⽂件⾥以“/”开头的⾏为注释⾏。
'排除多个内容时,使⽤分号“;”进⾏分隔。
'↓↓↓配置⽂件例⼦:↓↓↓
'/配置⽂件开始
'⽬录=D:\=System Volume Information;⽹络游戏;单机游戏;⼩游戏
'⽬录=C:\Program Files=qq;WinRAR
'⽂件=D:\⽹络游戏=⽂件1.exe;⽂件2.exe
'/配置⽂件结束
'''''''''''''说明完''''''''''''
Dim Fso,Listfile,objListfile
Listfile = "" '设置配置⽂件路径,如果配置⽂件和脚本放在⼀起,请保持原样If Listfile = "" Then Listfile = "Listfile.ini"
Set Fso = CreateObject("Scripting.FileSystemObject")
On Error Resume Next
Set objListfile = Fso.OpenTextFile(Listfile,1)
If Err Then
err.Clear
Msgbox "没有到配置⽂件 "&Listfile,16,"错误"
WScript.quit
End If
On Error GoTo 0
Dim flnum,fdnum,t1,t2,tm
flnum=0
fdnum=0
t1 = timer()
Dim Myline,LineArr,ListArr
Do While objListfile.AtEndOfStream <> True
Myline = LCase(Replace(objListfile.ReadLine,"==","="))
If Left(Myline,1) = "/" Then
'objListfile.SkipLine
ElseIf CheckLine(Myline) = 2 Then
LineArr = Split(Myline,"=")
'DoFolder = LineArr(1)
ListArr = Split(LineArr(2),";")
'MsgBox LineArr(0)
If LineArr(0) = "⽬录" Then DelFolder LineArr(1),ListArr
If LineArr(0) = "⽂件" Then DelFile LineArr(1),ListArr
End If
Loop
t2 = timer()
tm=cstr(int(( (t2-t1)*10000 )+0.5)/10)
MsgBox "扫描完毕,共删除 "&fdnum&" 个⽬录, "&flnum& "个⽂件。"& vbCrLf &"耗时 "&tm&" 毫秒",64,"执⾏完毕" '不需要显⽰报告的话,注释掉上⾯这⼀⾏
Set Fso=NoThing
WScript.quit
Sub DelFolder(Folder,ListArr)
Dim objFolder,subFolders,subFolder
Set objFolder=Fso.Getfolder(Folder)
Set subFolders=objFolder.subFolders
For Each subFolder In subFolders
If Not InArray(LIstArr,LCase(subFolder.name)) Then
On Error Resume Next
subfolder.Delete(True)
If Err Then
err.Clear
Msgbox "不能删除⽬录,请检查 "&subFolder,16,"错误"
Else
fdnum = fdnum + 1
End If
On Error GoTo 0
End If
Next
End Sub
Sub DelFile(Folder,ListArr)
Dim objFolder,Files,File
Set objFolder=Fso.Getfolder(Folder)
Set Files=objFolder.Files
For Each File In Files
If Not InArray(LIstArr,LCase(File.name)) Then
On Error Resume Next
File.Delete(True)
If Err Then
err.Clear
Msgbox "不能删除⽂件,请检查 "&File,16,"错误"
Else
flnum = flnum + 1
End If
On Error GoTo 0
End If
Next
End Sub
Function CheckLine(strLine)
Dim LineRegExp,Matches
Set LineRegExp = New RegExp
LineRegExp.Pattern = ".=."
LineRegExp.Global = True
Set Matches = LineRegExp.Execute(strLine)
CheckLine = unt
End Function
Function InArray(Myarray,StrIn)
Dim StrTemp
InArray = True
For Each StrTemp In Myarray
If StrIn = StrTemp Then
Exit Function
Exit For
End If
Next
InArray = False
End Function
!获得特定⽂件夹的路径(例如当前⽤户的桌⾯在磁盘中的实际位置,等等,相当于vc中的SHGetSpecialFolderPath()函数)
Set wsShell = CreateObject("WScript.Shell")
DesktopPath = wsShell.SpecialFolders("Desktop")
!获取当前⽤户名称
Set WshNetwork = WScript.CreateObject("WScript.Network")
UserName= WshNetwork.UserName
!获取系统变量%SystemRoot%(当然其他的系统变量可以类推,只是不只是不是都要通过PROCESS中转⼀下)
Set fso = CreateObject("Scripting.FileSystemObject")
Set WshSysEnv = wsShell.Environment("PROCESS")
SystemRoot = WshSysEnv("WINDIR")
!将域⽤户或租添加到本地组
Set objGroup = GetObject("WinNT://./Administrators")
Set objUser = GetObject("WinNT://testnet/Engineers")
objGroup.Add(objUser.ADsPath)
!修改本地管理员密码
Set objcnlar = GetObject("WinNT://./administrator, user")
objcnla.SetPassword "P@ssW0rd"
objcnla.SetInfo
!弹出 YES or NO 的对话框,不同的选择执⾏不同的代码
intAnswer = Msgbox("Do you want to delete these files?", vbYesNo, "Delete Files")
If intAnswer = vbYes Then
Msgbox "You answered yes."
Else Msgbox "You answered no."
End If
!运⾏CMD命令⾏命令
set ateobject("wscript.shell")
obshell.run ("ipconfig"),,true
如果要运⾏的命令中包含双引号,可使⽤&chr(34)&代替
!忽略代码错误继续执⾏
On Error Resume Next
放置于代码的最开头,当代码运⾏出错后并不停⽌跳出⽽是继续执⾏下⼀条。适当应⽤会很有效果。
!破解下载限制
DIM WSH
SET WSH=WSCRIPT.CreateObject("WSCRIPT.SHELL")
WSH.POPUP("本程序的作⽤是解决⽆法下载的问题")
WSH.POPUP("特别是在注册表禁⽤的情况下破解")
WSH.POPUP("由曾诚制作")
WSH.Regwrite"HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\3\1803",0,"REG_DWORD" WSH.POPUP("现在您可以下载程序了!")
!读本机“计算机名”
'ReadComputerName.vbs
Dim ReadComputerName
Set ReadComputerName=WScript.CreateObject("WScript.Shell")
Dim ComputerName,RegPath
RegPath="HKLM\System\CurrentControlSet\Control\ComputerName\ComputerName\ComputerName" ComputerName=ReadComputerName.RegRead(RegPath)
MsgBox("计算机名为"&ComputerName)
!隐藏快捷⽅式图标上的⼩箭头
'Hidden.vbs
Dim HiddenArrowIcon
Set HiddenArrowIcon=WScript.CreateObject("WScript.Shell")
Dim RegPath1,RegPath2
RegPath1="HKCR\lnkfile\IsShortCut"
RegPath2="HKCR\piffile\IsShortCut"
HiddenArrowIcon.RegDelete(RegPath1)
HiddenArrowIcon.RegDelete(RegPath2)
!改造“开始”菜单
'ChangeStartMenu.vbs
Dim ChangeStartMenu
Set ChangeStartMenu=WScript.CreateObject("WScript.Shell")
RegPath="HKCR\Software\Microsoft\Windows\CurrentVersion\Policies\"
Type_Name="REG_DWORD"
Key_Data=1
StartMenu_Run="NoRun"
StartMenu_Find="NoFind"
StartMenu_Close="NoClose"
Sub Change(Argument)
ChangeStartMenu.RegWrite RegPath&Argument,Key_Data,Type_Name
MsgBox("Success!")
End Sub
Call Change(StartMenu_Run) '禁⽤“开始”菜单中的“运⾏”功能
Call Change(StartMenu_Find) '禁⽤“开始”菜单中的“查”功能
Call Change(StartMenu_Close) '禁⽤“开始”菜单中的“关闭系统”功能
!向Windows中添加⾃启动程序
该程序能在开机时⾃动运⾏。
'AddAutoRunProgram.vbs
'假设该程序在c:\myfile⽂件夹中,⽂件名为

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。