(imported comment written by SystemAdmin)
So this is what I’ve changed my action to:
// store the file location – store the file location or (“C:\Program Files\Software\config.cfg”;“C:\Software\config.cfg”)
parameter “filename” = “{pathname of file (“C:\Program Files\Software\config.cfg”) whose (exists lines whose (it as lowercase contains “HostPort=”)of it )}”
parameter “textToReplace” = “HostPort=”
parameter “newText” = “//HostPort=”
// 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) ) ) of lines of file (parameter “filename”)}
// backup the old file
move “{parameter “filename”}” “{parameter “filename”}.bak”
// replace with the new file
move __appendfile “{parameter “filename”}”
and I’m getting
Completed
// store the file location – you can list multiple files locations, but if more than one of the locations exist, then the next line will fail
Failed
parameter “filename” = “{pathname of file (“C:\Program Files\Software\config.cfg”) whose (exists lines whose (it as lowercase contains “HostPort=”)of it )}”
parameter “textToReplace” = “HostPort=”
parameter “newText” = “//HostPort=”
// 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) ) ) of lines of file (parameter “filename”)}
// backup the old file
move “{parameter “filename”}” “{parameter “filename”}.bak”
// replace with the new file
move __appendfile “{parameter “filename”}”