Insert_Remove_Services

Dieses Script lässt sich als Custom-Actions (Embedded Code) in ein MSI einbauen.
In der vorliegenden Form ist esauf die SAP-Services abgestimmt.

Das Script legt während der Laufzeit ein Flagfile an.

option explicit
'on error resume next

dim wshell, fso, filein, fileout, i, n, datei
dim srcfile, destfile, sap_ports, old_sap_ports
dim checkfilein

set wshell=createobject("wscript.shell")
set fso = createobject("scripting.filesystemobject")

'Removing old Version
wshell.run "%SystemRoot%\System32\msiexec.exe" & " /X {5660E509-F02A-41DF-8A07-90E7BF8D4A31} /QN /L*V " & """%SystemRoot%\BSS_Logging\8R2205XX100 Add SAP BI systems to Services file 1.0__UNINSTALL.txt"""

'Removing flagfile from old version
if fso.fileexists ("C:\Temp\8R2205XX100_DONE.txt") then
fso.deletefile "C:\Temp\8R2205XX100_DONE.txt"
end if

srcfile ="C:\Windows\System32\drivers\etc\services"

'new ports for SAP
sap_ports=array("sapmsTB0 3600/tcp","sapmsQB9 3600/tcp","sapmsPB9 3600/tcp","sapmsTBI 3601/tcp","sapmsQBI 3601/tcp","sapmsPBI 3601/tcp","sapmsTBN 3601/tcp","sapmsQBN 3601/tcp","sapmsPBN 3601/tcp","sapmsVBI 3601/tcp","sapmsXBN 3601/tcp")


'Not really necessary, but this makes it better
destfile = "C:\Windows\System32\drivers\etc\services"

'for being sure
fso.copyfile destfile, "C:\Windows\Temp\services.sik"


Set FileIn  = FSO.OpenTextFile(srcfile, 1 )                        ' Datei zum Lesen öffnen 
    i = 0                   : ReDim Preserve Zeile(i)

 Do While Not (FileIn.atEndOfStream)                             ' wenn Datei nicht zu ende ist, weiter machen
   i = UBound( Zeile ) + 1 : ReDim Preserve Zeile(i) : Zeile(i) = FileIn.Readline
    Loop

'If UBound( Zeile ) < 1 Then 
'      i = UBound( Zeile )     : ReDim Preserve Zeile(i) : Zeile(i) = "Leerdatei"
'End If

FileIn.Close
Set FileIn  = nothing


Set FileOut  = FSO.OpenTextFile( destfile , 2, true) ' Datei zum Schreiben öffnen; 2: immer neu anlegen
old_sap_ports=array("sapmsTB0 3600/tcp","sapmsTB0 3601/tcp","sapmsQB9 3600/tcp","sapmsQB9 3601/tcp","sapmsPB9 3600/tcp","sapmsPB9 3601/tcp","sapmsTBI 3600/tcp","sapmsTBI 3601/tcp","sapmsQBI 3600/tcp","sapmsQBI 3601/tcp","sapmsPBI 3600/tcp","sapmsPBI 3601/tcp","sapmsTBN 3600/tcp","sapmsTBN 3601/tcp","sapmsQBN 3600/tcp","sapmsQBN 3601/tcp","sapmsPBN 3600/tcp","sapmsPBN 3601/tcp","sapmsVBI 3600/tcp","sapmsVBI 3601/tcp","sapmsXBN 3600/tcp","sapmsXBN 3601/tcp")


  for i = LBound( Zeile ) to UBound( Zeile )
 
 for n=0 to ubound(old_sap_ports)

   if zeile(i)=old_sap_ports(n) then
    i=i+1
   end if
   
 next
 
 if i<=ubound(zeile) then
  if zeile(i)<>"" then
   FileOut.WriteLine(Zeile(i))
  end if
 end if
  next
 
 fileout.close
 set fileout=nothing
 

'appending new ports
set fileout=fso.opentextfile ("C:\Windows\System32\drivers\etc\services",8,true)

for i=0 to ubound (sap_ports)
fileout.writeline sap_ports(i)
Next

fileout.close
set fileout=nothing
 
set checkfilein=fso.opentextfile ("C:\Temp\AddSapServicesV2_DONE.txt",2,true)
checkfilein.writeline "Customizing done."
checkfilein.close

 

  • Mittwoch, 14 März 2018

Leave a comment

You are commenting as guest.