(imported topic written by anthonymap91)
I am trying to just change text in a file. The action i have completes successful, but does not appear to change the file. Please help.
original content of file:
“managedby=DI-Managed-EIT,patchstatus=patch-now,”
Need changed to:
“managedby=DI-Managed-EIT,patchstatus=patch-complete,”
Action:
// store the text to replace
parameter “textToReplace” = “patch-now”
//store text to put in place***
//OS:win
if { name of operating system as string as lowercase contains “win”}
parameter “newtext” = “patch-complete”
parameter “filename-win” = “{pathname of file (“C:\WINDOWS\system32\DIINFO.txt”) whose (exists lines whose (it contains “patch-now”)of it )}”
// iterate through the file replacing lines as necessary
appendfile {concatenation “%0d%0a” of ( if (it contains (parameter “textToReplace”)) then ((preceding text of first (parameter “textToReplace”) of it) & (parameter “newtext”) & (following text of first (parameter “textToReplace”) of it) ) else it ) of lines of file (parameter “filename-win”)}