/build/static/layout/Breadcrumb_cap_w.png

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

0 Comments   [ + ] Show comments

Answers (8)

Posted by: brenthunter2005 18 years ago
Fifth Degree Brown Belt
0
Have a search through the forums, as this has been discussed and solutions posted previously.
Posted by: noodles187 18 years ago
Orange Belt
0
Sorry to be thick , but could not find any as i've searched before posting
Posted by: brenthunter2005 18 years ago
Fifth Degree Brown Belt
0
Try this link: [link]http://itninja.com/question/installshield-vs-wise-for-repackaging40&mpage=1&key=hostsຜ[/link]
Posted by: noodles187 18 years ago
Orange Belt
0
Thanks Mr. B hunter, but that post really does not say much, i'm sure the guy who posted it also did not get anything out of the replies
Posted by: brenthunter2005 18 years ago
Fifth Degree Brown Belt
0
Sorry, it was this part I was referring to:

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: noodles187 18 years ago
Orange Belt
0
Thanks B hunter, Thats worked
Posted by: noodles187 18 years ago
Orange Belt
0
Thanks B hunter, Thats worked
Posted by: DevGowda 18 years ago
Orange Belt
0
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
Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.
 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ