Hi ,

I have to add some entries to <Drivers>\etc\services.txt file as a part of package.
Kindly suggest if it can be done through Wise 7.0

Any comments are most welcome !
0 Comments   [ + ] Show Comments

Comments

Please log in to comment

Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.

Answers

0
There is no native functionality in Wise (or InstallShield, for that matter)to handle these files. Your best bet is to find a script and run it as a Custom Action. Note that most of the examples I've come across fail to make back-ups, nor do they check whether or not a proposed entry already exists in the file, nor whether the change was made successfully. You may or may not want to add such functionality to any script you find, depending on your level of paranoia.
Answered 09/19/2008 by: VBScab
Red Belt

Please log in to comment
0
Thnks a lot , that was such a valuable information for me .
Due to time shortage , I cann't do R n D for the script , Any idea where I can get a readymade script, modifiications I can make .
Answered 09/19/2008 by: dpu_bansal83
Orange Belt

Please log in to comment
0
Google?

And to be fair to VBScab you didnt ask for HOW to do it, mearly IF Wise could do it.
Answered 09/19/2008 by: Inabus
Second Degree Green Belt

Please log in to comment
0
Thanks for your info
Ya true ..but as it cann't be done through wise , so we need to use custom action ..
Google is the final distination , just wanted to save time if anybody already got such script.
Answered 09/19/2008 by: dpu_bansal83
Orange Belt

Please log in to comment
0
Because I'm *such* a nice guy, I looked to see if I could find where I had obtained a script I've used a couple of times to write to the HOSTS file (which is essentially the same as SERVICES). It was here http://www.codeproject.com/KB/vbscript/ReadWriteWinHostFile.aspx
Answered 09/19/2008 by: VBScab
Red Belt

Please log in to comment
0
ORIGINAL: dpu_bansal83

but as it cann't be done through wise , so we need to use custom action ..

Well, both yes and not.
You could execute a wisescript as a custom action to update the services file, yes there is no .txt extension (etc\services)
Answered 09/19/2008 by: AngelD
Red Belt

Please log in to comment
0
Is that possible that wise just append the values from one file to another instead of overwriting or repalacing.
e.g. text1 file is included in installation of package through wise having text as "Deepak" .and there is already text1 file , havving text as "Bansal", present at the specified location in system

Is it possible that wise just adds the content of text 1 file ( which is totally different from system text1) in system's text1 file so that the final result would become "Deepak Bansal" , spacing doesn't matter
Answered 09/19/2008 by: dpu_bansal83
Orange Belt

Please log in to comment
0
...possible that wise just append the values from one file to another...

it is impossible to become a good packager without getting your hands dirty with some scripting. Rather than shy away from it, immerse yourself & save yourself a lot of headache in the future... especially in this case where it is a relatively simple task to accomplish since 90% the work has been done for you...
Answered 09/19/2008 by: kiptek
Second Degree Green Belt

Please log in to comment
0
I have writen a wise script to do that (Appending).
create a txt file with the entries that needed to be updated to the services file. and include it in the package (msi). then write a custom action (wise script) to read the text file into a variable. and write the variable to the end of services file. you can use "insert line" from wise script to write to the services file. put this custom action in deffered execution just before install finalise. and condition it as "not installed" and as an additional messure create a regitry entry in the package msi under HKLM\Software\.......\ServiceFileModified to 0. and in the wise script first check if this registry key is 0 then only modify the services file and in the end of the script change the ServiceFileModified value to 1. so that the services file is modified only once and there are no multiple entries because of the script running multiple times.

And also create another files similar to this to delete the entries during uninstall. and condition is as REMOVE~="ALL". for a clean uninstall.
Answered 09/19/2008 by: bheers
Second Degree Blue Belt

Please log in to comment
0
If you have searched APPDeploy, you would have found this -

http://itninja.com/blog/view/sysprep-"factory-mode"6
Answered 09/21/2008 by: reds4eva
Second Degree Blue Belt

Please log in to comment
0

' ****************************************************************************
' Name : ModService.vbs
' Description : Handles inserting services at installation time
' Usage : Used at packaging to insert CA to adapt services file
' Modifications :
'
'
' Date Version User Description
' ****************************************************************************
' 25/04/2006 V1.0 J. McFadyen Created initial script
'
' ****************************************************************************
' Script details: This script requires two or three command line args
' : if two args are supplied the script will delete an
' : entry from the services file
' : if three args are supplied the script will add an
' : entry to the services file
'
' Examples :
' ModService.vbs <Filename> <ServiceName> <ServicePort>
' ModService.vbs <Filename> <ServiceName>
'
' Adding an entry
' ModService.vbs c:\windows\system32\drivers\etc\services Test1 100/tcp
' ModService.vbs c:\windows\system32\drivers\etc\services Test1 100/udp
'
' Deleting an entry
' ModService.vbs c:\windows\system32\drivers\etc\services Test1
'
' ****************************************************************************
On Error Resume Next
Dim FileSysObj, strFileContents, intLocation, objArgs
Set FileSysObj = CreateObject("Scripting.FileSystemObject")
Set objArgs = WScript.Arguments
'3 Arguments is Set, 2 is Delete
If objArgs.Count = 2 Then
DeleteService objArgs(0), objArgs(1)
Else
SetService objArgs(0), objArgs(1), objArgs(2)
End If

'Opens the file, gets the contents and searches for the host name on a non-comment line
'Leaves strFileContents with the contents and intLocation pointing to the start of the line
Sub LocateService(strFileName, strServiceName)
Err.Clear
Dim objFile, strLine
Set objFile = FileSysObj.OpenTextFile(strFileName, 1)
strFileContents = objFile.ReadAll()

intLocation = 0
Do
'Search for ServiceName
intLocation = InStr(intLocation+1, strFileContents, strServiceName, 1)

'Not found
If intLocation = 0 Then Exit Do

'Search back for the NewLine
intLocation = InStrRev(strFileContents, Chr(10), intLocation) + 1

'Grab the line
strLine = Trim(Mid(strFileContents, intLocation, InStr(intLocation, strFileContents, Chr(10)) - intLocation))

'Accept - unless it's comment, even if it does have our hostname
If Left(strLine, 1) <> "#" Then Exit Do

'Move forward
intLocation = InStr(intLocation, strFileContents, Chr(10))

'No more lines
If intLocation = 0 Then Exit Do
Loop

objFile.Close
End Sub
'Sets a service to a port value if it exists, adds it if it does not
Sub SetService(strFileName, strServiceName, strPort)
Dim objFile, strNewLine, intLineEnd
strNewLine = strServiceName & space((25-len(strServiceName))-len(strPort)) & strPort
msgbox strNewLine
LocateService strFileName, strServiceName
If intLocation > 0 Then

'Modify
intLineEnd = InStr(intLocation, strFileContents, Chr(10))

Set objFile = FileSysObj.OpenTextFile(strFileName, 2)
objFile.Write Left(strFileContents, intLocation-1)
objFile.WriteLine strNewLine
objFile.Write Mid(strFileContents, intLineEnd+1)
Else
'Append
Set objFile = FileSysObj.OpenTextFile(strFileName, 8, True)
objFile.WriteLine strNewLine
End If

objFile.Close
End Sub


'Deletes a line containing a service name
Sub DeleteService(strFileName, strServiceName)
Dim objFile, intLineEnd

LocateService strFileName, strServiceName
If intLocation > 0 Then
'Remove here
intLineEnd = InStr(intLocation, strFileContents, Chr(10))

Set objFile = FileSysObj.OpenTextFile(strFileName, 2)
objFile.Write Left(strFileContents, intLocation-1)
objFile.Write Mid(strFileContents, intLineEnd+1)
End If
End Sub
Answered 09/21/2008 by: jmcfadyen
Fifth Degree Black Belt

Please log in to comment
0
ORIGINAL: bheers
I have writen a wise script to do that (Appending).
create a txt file with the entries that needed to be updated to the services file. and include it in the package (msi). then write a custom action (wise script) to read the text file into a variable. and write the variable to the end of services file.
Does it check - as it should - that an existing entry already exists? Duplicate entries are sub-optimal in these files (i.e. SERVICES and HOSTS).
Answered 09/22/2008 by: VBScab
Red Belt

Please log in to comment
0
ORIGINAL: reds4eva
If you have searched APPDeploy, you would have found this -

http://itninja.com/blog/view/sysprep-"factory-mode"6
...another script with no error-trapping, no check for existing entries, etc, etc.
Answered 09/22/2008 by: VBScab
Red Belt

Please log in to comment
0
error trapping here

On Error Resume Next

*grin*
Answered 09/22/2008 by: jmcfadyen
Fifth Degree Black Belt

Please log in to comment
0
I had this same issue with SAP 7-10 and my solution was to create a seperate MSI to handle the changes to the Services file. Whenever changes need to be made (about 4 times in the past 9 months) I take a copy of the MSI, make the changes and then as part of the SAP deployment uninstall the current MSI with Services entries and install the newly edited version. The MSI is basically blank except for entries in the WItextFile table.
Answered 09/23/2008 by: My Name Is Earl
Senior Yellow Belt

Please log in to comment
Answer this question or Comment on this question for clarity