[腾讯QQ]
SvcDir=\\192.168.0.252\Game\NetGame\QQ
DisDir=E:\NetGame\QQ
RunDir=QQ.exe
RegDir=QQ.Reg
RunCmd=Play.bat
[QQ游戏]
SvcDir=\\192.168.0.252\Game\Ghost\QQGame
DisDir=E:\NetGame\QQGame
RunDir=QQGame.exe
RegDir=QQGame.Reg
RunCmd=Play.bat
[456游戏]
SvcDir=\\192.168.0.252\Game\Ghost\456Game
DisDir=E:\NetGame\456Game
RunDir=lobby.exe
RegDir=456Game.reg
RunCmd=Play.bat
如脚本名为abc.vbs
我可以用“abc.vbs QQ游戏”调用[QQ游戏]下的参数
P处理是可以实现的 VBS想了很久还没想到
下面的脚本只能读取INI里最后一节参数
On Error Resume Next
Set oShell = Wscript.CreateObject("Wscript.Shell")
Set objArgs = WScript.Arguments
For I = 0 to objArgs.Count - 1
Gamename = objArgs(I)
Next
SvcDir = GetIni (Gamename,"SvcDir","Gamecfg.ini")
DisDir = GetIni (Gamename,"DisDir","Gamecfg.ini")
RunDir = GetIni (Gamename,"RunDir","Gamecfg.ini")
RegDir = GetIni (Gamename,"RegDir","Gamecfg.ini")
RunCmd = GetIni (Gamename,"RunCmd","Gamecfg.ini")
Runfile = "Xxcopy " & SvcDir & " " & DisDir & " /pb/s/k/h/bi/yy/zy"
oShell.run Runfile,0,true
oShell.run RunCmd,0,true
oShell.run "Regedit /s RegDir",0,true
oShell.run RunDir
Function GetIni(strPrimary, strSubKey, strIniFilePath)
Dim fso, Myfile, intCount, strState
Set fso = CreateObject("Scripting.FileSystemObject")
Set Myfile = fso.OpenTextFile(strIniFilePath, 1, False, False)
With Myfile
Do Until .AtEndOfStream
If intCount = 0 Then
If .ReadLine = "[" & strPrimary & "]" Then
intCount = 1
End If
Else
strState = .ReadLine
If UCase(Left(strState, Len(strSubKey & "="))) = UCase(strSubKey & "=") Then
GetIni = Right(strState, Len(strState) - Len(strSubKey & "="))
End If
End If
Loop
.Close
End With
Set Myfile = Nothing
Set fso = Nothing
End Function