Имя пользователя:
Пароль:
 

Показать сообщение отдельно

Ветеран


Сообщения: 27449
Благодарности: 8088

Профиль | Отправить PM | Цитировать


Пробуйте:
Скрытый текст
Код: Выделить весь код
Option Explicit

Dim strSourceFile
Dim arrNames
Dim strContent


strSourceFile = "G:\css\cstrike\config.cfg"

arrNames = Array("grey", "silver", "blue", "red", "yellow")

With WScript.CreateObject("Scripting.FileSystemObject")
	If .FileExists(strSourceFile) Then
		With .OpenTextFile(strSourceFile)
			strContent = .ReadAll()
			.Close
		End With
		
		With WScript.CreateObject("VBScript.RegExp")
			.MultiLine = True
			.IgnoreCase = True
			.Pattern = "^(name +)(.*)$"
		
			If .Test(strContent) Then
				Randomize Timer
				
				strContent = .Replace(strContent, "$1""" & arrNames(Int((UBound(arrNames) - LBound(arrNames) + 1) * Rnd + LBound(arrNames))) & """")
			Else
				WScript.Echo "Can't find pattern [" & .Pattern & "] in source file [" & strSourceFile & "]."
				WScript.Quit 2
			End If
		End With
		
		With .CreateTextFile(strSourceFile, True)
			strContent = .Write(strContent)
			.Close
		End With
	Else
		WScript.Echo "Can't find source file [" & strSourceFile & "]."
		WScript.Quit 1
	End If
End With

WScript.Quit 0
Это сообщение посчитали полезным следующие участники:

Отправлено: 10:48, 16-02-2015 | #2