How To append in a file Using Wise
During Installation I need to append few values to the existing file.
For example
Two entries needs to appended during installation in the below mentioned file.
File: C:\WINDOWS\system32\drivers\etc\services
Entries:
knetd 2053/tcp
man 9535/tcp
How can we do this using WISE.
For example
Two entries needs to appended during installation in the below mentioned file.
File: C:\WINDOWS\system32\drivers\etc\services
Entries:
knetd 2053/tcp
man 9535/tcp
How can we do this using WISE.
0 Comments
[ + ] Show comments
Answers (2)
Please log in to answer
Posted by:
fetgor
18 years ago
Posted by:
brenthunter2005
18 years ago
Here are two vbscript custom actions that can be used:
CustomAction_AddToHostsFile
Condition: NOT Installed AND NOT REMOVE~="ALL"
CustomAction_RemoveFromHostsFile
Condition: REMOVE~="ALL"
CustomAction_AddToHostsFile
Condition: NOT Installed AND NOT REMOVE~="ALL"
Set objShell = CreateObject("WScript.Shell")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile(objShell.ExpandEnvironmentStrings("%windir%") & "\SYSTEM32\Drivers\etc\services.",8)
objFile.WriteLine "knetd 2053/tcp"
objFile.WriteLine "man 9535/tcp"
objFile.Close
CustomAction_RemoveFromHostsFile
Condition: REMOVE~="ALL"
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objShell = CreateObject("WScript.Shell")
Set objFile = objFSO.OpenTextFile(objShell.ExpandEnvironmentStrings("%windir%") & "\System32\drivers\etc\services.", 1)
strContents = objFile.ReadAll()
objFile.Close
strOldText = "knetd 2053/tcp"
strOldText2 = "man 9535/tcp"
strNewText =""
strContents = Replace(strContents, strOldText, strNewText)
strContents = Replace(strContents, strOldText2, strNewText)
Set objFile = objFSO.OpenTextFile(objShell.ExpandEnvironmentStrings("%windir%") & "\System32\drivers\etc\services.", 2)
objFile.Write strContents
objFile.Close
Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.
so that the conversation will remain readable.