java deployment.properties configured via .vbs

Option Explicit

 

Dim objShell, objFSO, fsofol, fsofil, origine, dest, cartella, OggTextStreamR, OggTextStreamW, stringa, stringToWrite, OggFileo, OggFiled, OggFile, usrName, f, i, j, arryStrngs, newCartella, stri, arryStri, fileAll

 

Set objShell = WScript.CreateObject("WScript.Shell")

usrName = objShell.expandEnvironmentStrings("%USERNAME%")

Set objFSO = CreateObject("Scripting.FileSystemObject")

Set fsofol = CreateObject("Scripting.FileSystemObject")

cartella = "C:\Users\" & usrName & "\AppData\LocalLow\Sun\Java\Deployment"

Set fsofil = CreateObject("Scripting.FileSystemObject")

origine="C:\Users\" & usrName & "\AppData\LocalLow\Sun\Java\Deployment\deployment.properties"

dest="C:\Users\" & usrName & "\AppData\LocalLow\Sun\Java\Deployment\deployment.properties.temp"

‘ scrivere le opzioni da inserire o aggiornare nel file
‘ "C:\Users\%username%\AppData\LocalLow\Sun\Java\Deployment\deployment.properties"
‘ separate da un ";"
‘ ES: deployment.security.mixcode=HIDE_RUN;deployment.security.revocation.check=NO_CHECK)

stringToWrite = split("deployment.security.mixcode=HIDE_RUN;deployment.security.revocation.check=NO_CHECK", ";")

if not fsofol.FolderExists(cartella) then

                arryStrngs = split(cartella,"\")

                newCartella = arryStrngs(0)

                For i = 0 to UBound(arryStrngs)

                               if i > 0 then

                                               newCartella = newCartella & "\" & arryStrngs(i)

                               end if

                               if not fsofol.FolderExists(newCartella) then

                                               fsofol.CreateFolder(newCartella)

                               end if

                Next

                Set OggFile = fsofil.CreateTextFile(origine, True)

                set OggFile = fsofil.GetFile(origine)

                Set OggTextStreamW = OggFile.OpenAsTextStream(8)

                For each stri in stringToWrite

                               OggTextStreamW.WriteLine stri

                next

                OggTextStreamW.Close

else if not fsofil.FileExists (origine) then

                Set OggFile = fsofil.CreateTextFile(origine, True)

                set OggFile = fsofil.GetFile(origine)

                Set OggTextStreamW = OggFile.OpenAsTextStream(8)

                For each stri in stringToWrite

                               OggTextStreamW.WriteLine stri

                next

                OggTextStreamW.Close

 else

                Set OggFileo = fsofil.GetFile(origine)

                Set OggTextStreamR = OggFileo.OpenAsTextStream(1)

                Set OggFiled = fsofil.CreateTextFile(dest, True)

                set OggFiled = fsofil.GetFile(dest)

                Set OggTextStreamW = OggFiled.OpenAsTextStream(2)

                fileAll = split(OggTextStreamR.ReadAll,vbCrLf)

                For i = 0 to Ubound(stringToWrite)

                               arryStri = split(stringToWrite(i),"=")

                               j = 0

                               For j = 0 to Ubound(fileAll)

                                               stringa=fileAll(j)

                                               if StrComp(Left(stringa, Len(arryStri(0))),arryStri(0)) = 0 then

                                                               fileAll(j)=stringToWrite(i)

                                                               f=1

                                               end if

                                               if f = 0 AND j = Ubound(fileAll) then

                                                               j=j+1

                                                               ReDim Preserve fileAll(j)

                                               ‘ReDim ridimensiona l’array alla dimensione j,
                                               ‘Preserve evita di perdere il contenuto dell’array alla funzione ReDim

                                                               fileAll(j)=stringToWrite(i)

                                               end if

                               next

                               f=0

                next

                For each stringa in fileAll

                               OggTextStreamW.WriteLine stringa

                next

                OggTextStreamR.Close

                OggTextStreamW.Close

                objFSO.copyFile dest,origine,True

                OggFiled.Delete

                end if

end if

 

rif: http://docs.oracle.com/javase/6/docs/technotes/guides/deployment/deployment-guide/properties.html

rif: http://docs.oracle.com/javase/7/docs/technotes/guides/deployment/deployment-guide/properties.html

Lascia un commento

Inserisci i tuoi dati qui sotto o clicca su un'icona per effettuare l'accesso:

Logo WordPress.com

Stai commentando usando il tuo account WordPress.com. Chiudi sessione / Modifica )

Foto Twitter

Stai commentando usando il tuo account Twitter. Chiudi sessione / Modifica )

Foto di Facebook

Stai commentando usando il tuo account Facebook. Chiudi sessione / Modifica )

Google+ photo

Stai commentando usando il tuo account Google+. Chiudi sessione / Modifica )

Connessione a %s...