Try this, over at least two turn ends and watch what is written to the command prompt window. There should be a " - StartTurn_moors found in log" line for each turn the moors have, likewise for the other four factions of this script.
Code:
Dim strLogFile
Dim strLine1
Dim blnAnyFound
strProcess = "kingdoms.exe"
strComputer = "."
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oWSH = CreateObject("WScript.Shell")
sCurDir = oFSO.GetParentFolderName(WScript.ScriptFullName)
Function IsProcessRunning( strServer, strProcess )
Dim Process, strObject
IsProcessRunning = False
strObject = "winmgmts://" & strServer
For Each Process in GetObject( strObject ).InstancesOf( "win32_process" )
If UCase( Process.name ) = UCase( strProcess ) Then
IsProcessRunning = True
Exit Function
End If
Next
End Function
strLogFile = oWSH.CurrentDirectory & "\logs\system.log.txt"
Sub ClearFile()
Set fLog = oFSO.OpenTextFile(strLogFile,2,1)
fLog.Write ""
' fLog.Close
End Sub
Function FindText(isText)
FindText = False
If oFSO.FileExists(strLogFile) Then
Set fLog = oFSO.OpenTextFile(strLogFile,1,1)
Do While Not fLog.AtEndOfStream
strLine1 = fLog.ReadLine
If isText = strLine1 Then
FindText = True
fLog.Close
ClearFile
Exit Function
End If
Loop
fLog.Close
Else
WScript.Echo "log file not found"
End If
End Function
Do While True
blnAnyFound = False
if FindText("StartTurn_moors") Then
oFSO.CopyFile sCurDir & "\data\AiSet1\*.*", sCurDir & "\data\", True
WScript.Echo " - StartTurn_moors found in log"
blnAnyFound = True
End if
if FindText("StartTurn_hre") Then
oFSO.CopyFile sCurDir & "\data\AiSet2\*.*", sCurDir & "\data\", True
WScript.Echo " - StartTurn_hre found in log"
blnAnyFound = True
End if
if FindText("StartTurn_england") Then
oFSO.CopyFile sCurDir & "\data\AiSet3\*.*", sCurDir & "\data\", True
WScript.Echo " - StartTurn_england found in log"
blnAnyFound = True
End if
if FindText("StartTurn_france") Then
oFSO.CopyFile sCurDir & "\data\AiSet4\*.*", sCurDir & "\data\", True
WScript.Echo " - StartTurn_france found in log"
blnAnyFound = True
End if
if FindText("StartTurn_spain") Then
oFSO.CopyFile sCurDir & "\data\AiSet5\*.*", sCurDir & "\data\", True
WScript.Echo " - StartTurn_spain found in log"
blnAnyFound = True
End if
If Not blnAnyFound Then
'WScript.Echo " - nothing found in log"
End If
WScript.Sleep 10000
if ( IsProcessRunning( strServer, strProcess ) = False ) Then
WScript.Quit
End if
Loop