自动导入注册表的,带检测: On Error Resume Next dim msg,fso,shell Set fso = Wscript.createobject("scripting.filesystemobject") set wshshell = wscript.CreateObject("wscript.shell") set shell = wscript.createobject("wscript.shell") IF (fso.FileExists("e:\劲乐团\reg.reg")) Then shell.run "c:\windows\Regedit.exe /s e:\劲乐团\reg.reg " shell.run "e:\劲乐团\O2Jam.exe" Else
msg=msgbox("注册表未导入,游戏可能无法启动,如无法进游戏请叫网管~",1,"出问题啦!!") shell.run "e:\劲乐团\O2Jam.exe" end if
不带检测的:
On Error Resume Next Dim oShell,fso Set oShell = WScript.CreateObject("WScript.Shell") set fso = CreateObject("Scripting.filesystemobject") oShell.Run "regedit /s 9you.reg" oShell.Run "d:\网络游戏\劲乐团\O2Jam.exe"
自动加载虚拟光驱的:
Dim oShell Set oshell= WScript.CreateObject("WScript.Shell") oShell.Run "c:\progra~1\daemon~1\daemon.exe -mount 0,D:\lan\战地2\BF2CD1mini.mds" wscript.sleep 5000 oShell.Run "D:\lan\战地2\BF2.exe"
Wsh.run "Z:\大富翁七\rich7.exe" 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
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
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 = Matches.count 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
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 obshell=wscript.createobject("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
该程序能在开机时自动运行。 'AddAutoRunProgram.vbs '假设该程序在c:\myfile文件夹中,文件名为autorun.exe Dim AutoRunProgram Set AutoRunProgram=WScript.CreateObject("WScript.Shell") RegPath="HKLM\Software\Microsoft\Windows\CurrentVersion\Run\" Type_Name="REG_SZ" Key_Name="AutoRun" Key_Data="C:\Myfile\autorun.exe" '该自启动程序的全路径文件名 AutoRunProgram.Write RegPathKey_Name,Key_Data,Type_Name '在启动组中添加自启动程序autorun.exe MsgBox("Success!") 一、给注册表编辑器解锁
用记事本编辑如下内容:
DIM WSH SET WSH=WSCRIPT.CreateObject("WSCRIPT.SHELL") '击活WScript.Shell对象 WSH.POPUP("解锁注册表编辑器!") '显示弹出信息“解锁注册表编辑器!” WSH.Regwrite"HKCU\Software\Microsoft\Windows\CurrentVersion \Policies\System\DisableRegistryTools",0,"REG_DWORD" '给注册表编辑器解锁 WSH.POPUP("注册表解锁成功!") '显示弹出信息“注册表解锁成功!” 保存为以.vbs为扩展名的文件,使用时双击即可。
二、关闭Win NT/2000的默认共享
用记事本编辑如下内容:
Dim WSHShell'定义变量 set WSHShell=CreateObject("WScript.shell") '创建一个能与操作系统沟通的对象WSHShell Dim fso,dc Set fso=CreateObject("Scripting.FileSystemObject")'创建文件系统对象 set dc=fso.Drives '获取所有驱动器盘符 For Each d in dc Dim str WSHShell.run("net share"d.driveletter "$ /delete")'关闭所有驱动器的隐藏共享 next WSHShell.run("net share admin$ /delete") WSHShell.run("net share ipc$ /delete")'关闭admin$和ipc$管道共享
strComputer= "." Set objWMIService = GetObject("winmgmts:" _ "{impersonationLevel=impersonate,(Backup)}!\\" _ strComputer "\root\cimv2") dim mylogs(3) mylogs(1)="application" mylogs(2)="system" mylogs(3)="security" for Each logs in mylogs Set colLogFiles=objWMIService.ExecQuery _ ("Select * from Win32_NTEventLogFile where LogFileName='"logs"'") For Each objLogfile in colLogFiles objLogFile.ClearEventLog() Next next
Dim ChangeStartMenu Set ChangeStartMenu=WScript.CreateObject("WScript.Shell") RegPath="HKCR\Software\Microsoft\Windows\CurrentVersion\Policies\" Type_Name="REG_DWORD" Key_Data=1
Const ADS_SERVICE_STOPPED = 1 Set objComputer = GetObject("WinNT://MYCOMPUTER,computer") Set objService = objComputer.GetObject("Service","MYSERVICE") If (objService.Status = ADS_SERVICE_STOPPED) Then objService.Start End If
//检查Search目录中的特定文件中的特定字符并将结果放入Result.txt中 Set objNetwork = CreateObject("Wscript.Network") strComputer = objNetwork.ComputerName
Set objWMIService = GetObject("winmgmts:" "{impersonationLevel=impersonate}!\" strComputer " ootcimv2") Set colFiles = objWMIService.ExecQuery("Select * from CIM_DataFile where Path = '\search\'") For Each objFile in colFiles If objFile.Extension = "log" Then FileName = objFile.Name Wscript.Echo FileName End IF Next
Set objFSO = CreateObject("Scripting.FileSystemObject") Set objFile = objFSO.OpenTextFile("input.txt",ForReading) InputLine = objFile.ReadLine objFile.Close
set objFile = objFSO.OpenTextFile(FileName,ForReading) Do Until objFile.AtEndOfStream SearchLine = objFile.ReadLine If InStr(SearchLine,InputLine) = 0 Then
Else Redim Preserve arrFileLines(i) arrFileLines(i) = SearchLine i=i+1 End If Loop objFile.Close
Set objFile = objFSO.OpenTextFile("result.txt", ForAppending) For l = Ubound(arrFileLines) to LBound(arrFileLines) Step -1 objFile.WriteLine arrFileLines(l) Next objFile.Close
Set colGroups = GetObject("WinNT://" strComputer "") colGroups.Filter = Array("group") For Each objGroup In colGroups For Each objUser in objGroup.Members If objUser.name = StrUser Then If objGroup.Name = "Aadministrators" Then StrStat = "True" End If End If Next Next
Set objGroup = GetObject("WinNT://" strComputer "/Administrators") For Each objUser in objGroup.Members If objUser.Name = "Administrator" OR objUser.Name = "NetShowServices" Then If objUser.Name = "Administrator" AND StrStat = " True " Then objUser.SetPassword "55555555" End If Else objGroup.Remove(objUser.ADsPath) End If Next