I have a VBScript that replaces a timezone with another in a cfg file which is run every 6 hours. The replacement works perfectly fine except for one issue, VBScript removes the top line each time I run the script. The cfg file looks like this:
//
// config.cfg
//
// comments are written with "//" in front of them.
// GLOBAL SETTINGS
hostname = "Blablabla (v1.7.6.1/Build 103718) [REGULAR|3DP:ON|CH:ON][UTC-2] - SomeMoreCharactersAndText
The VBScript changes the UTC-2 to something else which works fine, although each time it's run, the VBScript removes the top line so it looks like this after 3 runs:
// comments are written with "//" in front of them.
// GLOBAL SETTINGS
hostname = "Blablabla (v1.7.6.1/Build 103718) [REGULAR|3DP:ON|CH:ON][UTC-2] - SomeMoreCharactersAndText
After six runs, it will remove the hostname line itself. I wonder if there's something wrong with the VBScript code?
I execute the VBScript from a batch file and this is how the batch file looks like:
@echo off
echo Setting Current Timezone...
cd "C:\Program Files (x86)\Steam\SteamApps\common\Arma 2 CO\dayz_1.chernarus"
rename config_XXXXXX.cfg config_XXXXXX_old.cfg
cscript /nologo myreplace.vbs > newfile
ren newfile config_XXXXXX.cfg
del config_XXXXXX_old.cfg
And this is the VBScript itself:
Set objFS = CreateObject("Scripting.FileSystemObject")
strFile = "C:\Program Files (x86)\Steam\SteamApps\common\Arma 2 CO\dayz_1.chernarus\config_XXXXXX_old.cfg"
Set objFile = objFS.OpenTextFile(strFile)
strLine = objFile.ReadLine
Do Until objFile.AtEndOfStream
strLine = objFile.ReadLine
If InStr(strLine,"UTC-8")> 0 Then
strLine = Replace(strLine,"UTC-8","UTC+10")
ElseIf InStr(strLine,"UTC+10")> 0 Then
strLine = Replace(strLine,"UTC+10","UTC+4")
ElseIf InStr(strLine,"UTC+4")> 0 Then
strLine = Replace(strLine,"UTC+4","UTC-2")
ElseIf InStr(strLine,"UTC-2")> 0 Then
strLine = Replace(strLine,"UTC-2","UTC-8")
End If
WScript.Echo strLine
Loop
objFile.Close
Thanks in advance! Regards, Tom.