Имя пользователя:
Пароль:  
Помощь | Регистрация | Забыли пароль?  

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

Ветеран


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

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


Вот примерная болванка на WSH (не знаю, зачем там две пустые строки предварительно добавлять, но, коль Вы так написали…):
Скрытый текст
Код: Выделить весь код
Option Explicit

Const ForReading   = 1
Const ForAppending = 8

Const TristateTrue       = -1


Dim strPattern
Dim strSourceFile

Dim strContent


strPattern    = "CommonCfgLocation=\\SQLSERVER\Common1C\1CESCmn.cfg"
strSourceFile = WScript.CreateObject("WScript.Shell").ExpandEnvironmentStrings("%AppData%\1C\1CEStart\1CEStart.cfg")

With WScript.CreateObject("Scripting.FileSystemObject")
	If .FileExists(strSourceFile) Then
		With .OpenTextFile(strSourceFile, ForReading, False, TristateTrue)
			strContent = .ReadAll()
			.Close
		End With
		
		If Not InStr(1, strContent, strPattern, vbTextCompare) > 0 Then
			With .OpenTextFile(strSourceFile, ForAppending, False, TristateTrue)
				.WriteBlankLines 2
				.WriteLine strPattern
				.Close
			End With
		End If
	Else
		WScript.Echo "Can't find source file [" & strSourceFile & "]."
		WScript.Quit 1
	End If
End With

WScript.Quit 0

Отправлено: 18:36, 09-03-2017 | #3