Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to insert text from file in other file

Status
Not open for further replies.

Seherezada

IS-IT--Management
Jun 7, 2010
3
PL
I have a problem,

i must insert text from file (one word) to other but

the test must be replaced in command

msiexec.exe /I \\tefnut\MOM\momagent.msi /norestart /qn /l*v "C:\MOMReinstall.log" MANAGEMENT_GROUP="TESTOWA" MANAGEMENT_GROUP_OPERATION="RemoveConfigGroup" MANAGEMENT_SERVER="CERBEROS" REINSTALL="all"

the text to replacement is TESTOWA

Could you help me?
 
your command should be driven by a parameter.
passed to your script as an argument.

ideally you would generate a master process for gathering all of your environmental data which applies to the client, you can then use all of those nice 'properties' to be supplied to all of your scripts, e.g





str2Run = "msiexec.exe /I \\tefnut\MOM\momagent.msi /norestart /qn /l*v "C:\MOMReinstall.log" MANAGEMENT_GROUP=%Me.momagent_managementgroup%MANAGEMENT_GROUP_OPERATION="RemoveConfigGroup" MANAGEMENT_SERVER="CERBEROS" REINSTALL="all""

Call ReplaceVariables(strRun [byref])

 
'in simpler less generic terms
'based on your 1st file being in a key=value format
'no worrying about case? or white space, serious lack of audit wscript.echos, option explicit blaa blaa
Set dicProperties = CreateObject("Scripting.Dictionary")
'comparemode?
Set objTS = FSO.OpenTextFile("config.txt")
Do While Not objTS.AtEndOfStream
strKey = ""
strValue = ""
strLine = ""
strLine = objTS.ReadLine
If InStr(strLine, "=") <> 0 Then
strKey = Left(strLine, InStr(strLine, "="))
strValue = Replace(strLine, strKey, "")
If Not dicProperties.Exists(strKey) Then
dicProperties.Add strKey, strValue
Else
dicProperties.Item(strKey) = strValue
End If
End If
Loop
objTS.Close
Set objTS = Nothing

'what are we really trying to do?
str2Run = "msiexec.exe /I \\tefnut\MOM\momagent.msi /norestart /qn /l*v "C:\MOMReinstall.log" MANAGEMENT_GROUP=%mom_managementgroup%MANAGEMENT_GROUP_OPERATION="RemoveConfigGroup" MANAGEMENT_SERVER="CERBEROS" REINSTALL="all""

Call StringReplace(dicProperties, str2Run)
Wscript.Echo str2Run


Sub StringReplace(ByVal dicProperties, ByRef strPassed)
Dim aKey
For Each aKey In dicProperties
If InStr(strPassed, "%" & aKey & "%") <> 0 Then
strPassed = Replace(strPassed, "%" & aKey & "%", dicPassed.Item(aKey))
End If
Next

End Sub
 
Ha! :D
Thank u so much :)
Mrmovie solution is good :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top