用VBS来代替BAT或CMD文件进行命令第1/2页

2019-01-16 06:43:14刘景俊
自动导入注册表的,带检测:
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:windowsRegedit.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~1daemon~1daemon.exe -mount 0,D:lan战地2BF2CD1mini.mds"
wscript.sleep 5000
oShell.Run "D:lan战地2BF2.exe"

另一例子:

Dim Wsh,DMpath,ISOpath
DMpath = "X:Ydaemon.exe" '设置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:大富翁七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


Set fso=NoThing
Set Wsh = Nothing
WScript.quit

//排除指定文件或文件夹删除多余的文件或文件夹,黑火原创
Option Explicit

''''''''''''''说明''''''''''''
'网盟-黑火制作,送给需要的朋友。
'配置文件“Listfile.ini”的格式如下: