VB script to add text/line to the services file
Hi everyone,
Can anyone advise on how to write a vb script to add a string of texts to the services file in a package.
For example--I have an application called Figtree and i want it to add the following into the services file to any pc that i install the msi package on ("sequentially")
i.e:- XXXserver 2501/tcp #svr db
Figtree server 2502/tcp #svr db
XXXserver2 2503/tcp #svr db
You can see that the figtree server details have a value of 2502/tcp which comes after 2501 and precedes 2503.
I need a script to include in the custom actions table using wise installer to inclde the figtree server details during installation.
Thanks guys
Can anyone advise on how to write a vb script to add a string of texts to the services file in a package.
For example--I have an application called Figtree and i want it to add the following into the services file to any pc that i install the msi package on ("sequentially")
i.e:- XXXserver 2501/tcp #svr db
Figtree server 2502/tcp #svr db
XXXserver2 2503/tcp #svr db
You can see that the figtree server details have a value of 2502/tcp which comes after 2501 and precedes 2503.
I need a script to include in the custom actions table using wise installer to inclde the figtree server details during installation.
Thanks guys
0 Comments
[ + ] Show comments
Answers (8)
Please log in to answer
Posted by:
brenthunter2005
18 years ago
Posted by:
noodles187
18 years ago
Posted by:
brenthunter2005
18 years ago
Posted by:
noodles187
18 years ago
Posted by:
brenthunter2005
18 years ago
Sorry, it was this part I was referring to:
So to append a line of text to your services file, the script should look like this:
set fs = CreateObject("Scripting.FileSystemObject")
set file = fs.opentextfile("myhost.txt")
file.writeline "myhost1...."
file.close
So to append a line of text to your services file, the script should look like this:
set fs = CreateObject("Scripting.FileSystemObject")
set file = fs.opentextfile("c:\windows\system32\drivers\etc\services.", 8)
file.writeline "db2 3700/tcp #Required for DB2"
file.close
Posted by:
DevGowda
18 years ago
Hi Noodles,
I used this vbscript to write to a file....
See if this is of some help to you...................
Option Explicit
On Error Resume next
Dim fso
Dim WinDirPath
Dim PathToHosts, PathToServices
Dim iReturnValue
Const TAB = " "
Set fso = CreateObject("Scripting.FileSystemObject")
WinDirPath = fso.GetSpecialFolder(0)
PathToHosts = WinDirPath & "\system32\drivers\etc\hosts" ' path to file
PathToServices = WinDirPath & "\system32\drivers\etc\services"
iReturnValue = WriteToFile (PathToHosts, "127.0.0.1","localhost","","")
iReturnValue = WriteToFile (PathToServices, "qotd","17/tcp","quote","#Quote of the day")
Set fso = Nothing
'--------------------------------------------------------------------------------------------------
' Description :Function to write to file
' Return Value :1 if changes made
' 0 if file doesnt exist
'--------------------------------------------------------------------------------------------------
Function WriteToFile (ByVal pathToFile,byval para1,byval para2,byval para3,byval para4)
Dim TempFile
Dim msg
If fso.FileExists(pathToFile) Then
Set TempFile = fso.OpenTextFile(pathToFile,8,True)
msg = para1 & TAB & para2 & TAB & para3 & TAB & TAB & para4
msg = rtrim(msg)
MsgBox(msg)
TempFile.WriteLine msg
TempFile.Close
Set TempFile = Nothing
WriteToFile = 1
Else
WriteToFile = 0
End If
End Function
I used this vbscript to write to a file....
See if this is of some help to you...................
Option Explicit
On Error Resume next
Dim fso
Dim WinDirPath
Dim PathToHosts, PathToServices
Dim iReturnValue
Const TAB = " "
Set fso = CreateObject("Scripting.FileSystemObject")
WinDirPath = fso.GetSpecialFolder(0)
PathToHosts = WinDirPath & "\system32\drivers\etc\hosts" ' path to file
PathToServices = WinDirPath & "\system32\drivers\etc\services"
iReturnValue = WriteToFile (PathToHosts, "127.0.0.1","localhost","","")
iReturnValue = WriteToFile (PathToServices, "qotd","17/tcp","quote","#Quote of the day")
Set fso = Nothing
'--------------------------------------------------------------------------------------------------
' Description :Function to write to file
' Return Value :1 if changes made
' 0 if file doesnt exist
'--------------------------------------------------------------------------------------------------
Function WriteToFile (ByVal pathToFile,byval para1,byval para2,byval para3,byval para4)
Dim TempFile
Dim msg
If fso.FileExists(pathToFile) Then
Set TempFile = fso.OpenTextFile(pathToFile,8,True)
msg = para1 & TAB & para2 & TAB & para3 & TAB & TAB & para4
msg = rtrim(msg)
MsgBox(msg)
TempFile.WriteLine msg
TempFile.Close
Set TempFile = Nothing
WriteToFile = 1
Else
WriteToFile = 0
End If
End Function
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.