Created
February 2, 2013 03:57
-
-
Save after-the-sunrise/4696058 to your computer and use it in GitHub Desktop.
Script to replace specified property value. Usage : replace.vbs ${filename} ${key} ${value}
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Option Explicit | |
Dim targetFile, propName, propValue | |
targetFile = WScript.Arguments(0) | |
propName = WScript.Arguments(1) | |
propValue = WScript.Arguments(2) | |
Dim objFS | |
Set objFS = CreateObject("Scripting.FileSystemObject") | |
Dim objTS, content, line | |
Set objTS = objFS.OpenTextFile(targetFile, 1, 0) | |
While objTS.AtEndOfStream = 0 | |
line = objTS.ReadLine | |
If InStr(line, propName) <> 0 Then | |
line = propName & "=" & propValue | |
WScript.Echo "Property Changed : " & line | |
End If | |
content = content & line & vbNewLine | |
Wend | |
objTS.Close | |
WScript.Echo content | |
' | |
' Uncomment to replace the input file | |
' | |
' Set objTS = objFS.CreateTextFile(targetFile, true) | |
' objTS.Write(content) | |
' objTS.Close |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment