WiseScript That Adds a Line to a File (Services File)
This Wise Script searches for a line in the services file. If it cannot find the line it ads it to the file. If it finds the line it overwrites it. Overwriting the line prevents the possibility of adding it repeatedly during a repair.
I use the services file as an example here, since that file gets modified most often, but this script can be used on other files as well.
Step 1
- Open the Wise Script Editor and Select the Script Editor tab.
- In the left pane, double click: Set Variable.
- In the Variable field type: ROOTDIR
- In the New Value field type: C:
- Click OK.
Step 2
- In the left pane, double click: Get Environment Variable.
- In the Env. Variable field type: windir
- In the Variable Name field type: WINDIR
- Click OK.
Step 3
- In the left pane, double click: Insert Line into Text file.
- In the Text to Insert field type: SERVERNAME 99999/tcp (this is an example).
- In the Search for Text field type: SERVERNAME 99999/tcp
- In the Insert Action field select: Replace line containing text.
- In the Match Criteria field select: Line containing search text.
- Click OK.
Save Wise Script and Test.



