Jump to content

Hi Im new here, Just want to share a nice script with you


 Share

Recommended Posts

Generally speaking installing programs with install switches is preferable then there is no screens for user to mess with whilst its installing.

I regularly install 10-15 programs all silent one after another in a matter of minutes

There is some info here to get you started

http://unattended.sourceforge.net/installers.php

Link to comment
Share on other sites

Thanks everyone for the support.

 

I now tryed to change something else,

If you have an older version of Java (7.0.*)

I what that the script will run,

I don't know how exactly i define this,   

If FileExists ( $sLocalFile ) or (Folder jre1.7.* exists) Then
      $PC_Vertion = FileGetVersion($sLocalFile, $FV_PRODUCTVERSION)
      MsgBox (0 , "Java Insallation - Information", "PC verstion found, installation will continue")
   Else
      MsgBox ( 0, "Java Insallation - Error", "Can't find PC file, installation will stop")
      Exit
     EndIf

I don't get it how i check the folder name if the name of the folder allwayes change accordion to the version

etc:

(Folder jre1.7.* exists)

jdk1.7.0_13

jre1.8.0_25

jre1.8.0_31

jre1.8.0_51

Edited by Orara
Link to comment
Share on other sites

Update:

 

I find solution.

Use FileFindFirstFile ()

Local $slocalOld = FileFindFirstFile ( "C:\Program Files\Java\jre1.7.*")



   ; Check the file on the pc, If the file dosnt exists, the script will stop
   If FileExists ( $sLocalFile ) Then
      $PC_Vertion = FileGetVersion($sLocalFile, $FV_PRODUCTVERSION)
      MsgBox (0 , "Java Insallation - Information", "PC verstion found, installation will continue")
   ElseIf $slocalOld == 1 Then
      MsgBox (0 , "Java Insallation - Information", "PC verstion found, installation will continue")
   Else
      MsgBox ( 0, "Java Insallation - Error", "Can't find PC file, installation will stop")
      Exit
     EndIf

 

Still have a problem,

 

Local $slocalOld = FileFindFirstFile ( "C:\Program Files\Java\jre1.7.*") ; Check if there is anther version of java Less then 8



   ; Check the file on the pc, If the file dosnt exists, the script will stop
   If FileExists ( $sLocalFile ) Then
      $PC_Vertion = FileGetVersion($sLocalFile, $FV_PRODUCTVERSION)
      MsgBox (0 , "Java Insallation - Information", "PC verstion found, installation will continue")
   ElseIf $slocalOld == 1 Then
      MsgBox (0 , "Java Insallation - Information", "PC verstion found, installation will continue")
   Else
      MsgBox ( 0, "Java Insallation - Error", "Can't find PC file, installation will stop")
      Exit
     EndIf

;   Visual text of the versions on the computer (This is created for testing if everything works); Debug
;   MsgBox (0, "Java", "Download version: " & $iDownloadVersion ); Debug
;   MsgBox ( 0, "Computer version" , "The Computer Version is: " & $PC_Vertion ); Debug
    MsgBox (0, "Test FileFindFirstFile", "This is a test of FileFindFirstFile: " & $slocalOld ) ; Debug

;    Chrck the Java Version on the Clint Mchine
      If $iDownloadVersion == $PC_Vertion or $slocalOld == -1 Then
         MsgBox (0, "Java is up to date", "You have the newest version of Java on your PC", 5)
         Exit
      Elseif $slocalOld == 1 or $iDownloadVersion <> $PC_Vertion  Then
         MsgBox (0, "Old Java", "You Have an old version of java, Click OK to Continue" , 10)
         InetGet ("http://javadl.sun.com/webapps/download/AutoDL?BundleId=107944", "Java - Setup.exe", $INET_DOWNLOADWAIT )

         If FileExists ( "Java - Setup.exe" ) & $Size > 4096 Then
            MsgBox ( 0, "File Exist", "Your file has been downloaded successfully installation will Continue")
         Else
            MsgBox ( 0, "File dont Exist", "Java - Setup.exe not found, installtion will stop")
            Exit
            EndIf

Cant get it work

Edited by Orara
Link to comment
Share on other sites

Using the "==" operator is only necessary when you want to do a strict string comparison. Most of the time "=" is enough.
See Operators section "Comparison Operators".

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Tanks,

And i find the problem,

 

The problem was that the "$PC_Vertion" var was null,

The code stop to operate.

 

The solution i find is to do the "$PC_Vertion" equal to 1.

 

If FileExists ( $sLocalFile ) Then
      $PC_Vertion = FileGetVersion($sLocalFile, $FV_PRODUCTVERSION)
      MsgBox (0 , "Java Insallation - Information", "PC verstion found, installation will continue")
   ElseIf $slocalOld = 1 Then
      $PC_Vertion = 1
      MsgBox (0 , "Java Insallation - Information", "PC verstion found, installation will continue1")
   Else
      MsgBox ( 0, "Java Insallation - Error", "Can't find PC file, installation will stop")
      Exit
     EndIf

;   Visual text of the versions on the computer (This is created for testing if everything works); Debug
;   MsgBox (0, "Java", "Download version: " & $iDownloadVersion ); Debug
;   MsgBox ( 0, "Computer version" , "The Computer Version is: " & $PC_Vertion ); Debug
    MsgBox (0, "Test FileFindFirstFile", "This is a test of FileFindFirstFile: " & $slocalOld & $PC_Vertion ) ; Debug

;    Chrck the Java Version on the Clint Mchine
      If $iDownloadVersion == $PC_Vertion or $slocalOld = -1 Then

 

I Dont know if this the smartest way,

But till now this is the solution i thinks of ,

 

If there is any other solution i'll be happy to here,

Best regards.

Link to comment
Share on other sites

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST APIErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) * Show_Macro_Values.au3 *

 

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * 

OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskSchedulerIE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related:How to get reference to PDF object embeded in IE * IE on Windows 11

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

I also encourage you to check awesome @trancexx code:  * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuffOnHungApp handlerAvoid "AutoIt Error" message box in unknown errors  * HTML editor

winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2023-04-24

Link to comment
Share on other sites

Im Familiar with 

java -version
java -XshowSettings:all

But How i can to compare the download visions with the spastic one on my computer with that.

this "java version "1.7.0_13"" output

Information is not help because the product version on the exe file that i downloaded is different....

  

Edited by Orara
Link to comment
Share on other sites

"deterrent"? You mean "different"?
You could use function SplitString to extract the version number.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

"deterrent"? You mean "different"?
You could use function SplitString to extract the version number.

different ----->

 

After thinking a Lot i find some "work around" in order this to works... i Use "Javapath" file location. 

And get the install version from "Javaws.exe" Shortcut, (java 8 and above)

z0JhKfj.png

 

ver 0.0.2

:sweating:

; This Script will cehck the Java version on this conputer, If the Verstion on the PC is an old version
; The Script will download a new version on Java and install it
; Created By Orara 8.8.2015
; https://www.autoitscript.com/forum/topic/174584-hi-im-new-here-just-want-to-share-a-nice-script-with-you/

#RequireAdmin
#include <InetConstants.au3>
#include <FileConstants.au3>
#include <MsgBoxConstants.au3>
#include <WinAPIFiles.au3>


MsgBox (0 , "New Java installtopm", "This program Made by Orara, Click OK to Continue")
;test script to download java and install it.
DLjava()

Func DLjava()
   Local $iDownloadVersion = FileGetVersion ( "Java - Setup.exe" , $FV_PRODUCTVERSION ) ; $iDownloadVersion Check the version that stored in the ROOT dir of the script (the installtion)
;~    Local $PC_VertionExists = FileGetVersion ( "C:\ProgramData\Oracle\Java\javapath\javaws.exe",  $FV_PRODUCTVERSION ); Check the version on the computer, this path is the path of Java 8 and above
   Local $sLocalFile = "C:\ProgramData\Oracle\Java\javapath\javaws.exe" ; Local folder destination for easy code
   Local $slocalOld = FileFindFirstFile ( "C:\Program Files\Java\jre1.7.*") ; Check if there is anther version of java Less then 8

   ; Check the file on the pc, If the file dosnt exists, the script will stop
   If FileExists ( $sLocalFile ) Then
      $PC_VertionExists = FileGetVersion($sLocalFile, $FV_PRODUCTVERSION)
      MsgBox (0 , "Java Insallation - Information", "PC verstion found, installation will continue")
   ElseIf $slocalOld = 1 Then
      $PC_VertionExists = 1
      $slocalOldExists = FileFindFirstFile ( "C:\Program Files\Java\jre1.7.*") ; Check if there is anther version of java Less then 8
      MsgBox (0 , "Java Insallation - Information", "PC verstion found, installation will continue")
   Else
      Local $iAnswer = MsgBox ($MB_OKCANCEL , "Java Insallation - Error", "Can't find PC file, Press OK to Continue or Cancel to abort")
      If $iAnswer = 1 Then
          $PC_VertionExists = 1
          $slocalOldExists = 2
          $iDownloadVersion = 4
      Else
           MsgBox (0 , "Java Insallation - Information", "Installation will be aborted" )
           Exit
      EndIf
   EndIf



;   Visual text of the versions on the computer (This is created for testing if everything works); Debug
;   MsgBox (0, "Java", "Download version: " & $iDownloadVersion ); Debug
;   MsgBox ( 0, "Computer version" , "The Computer Version is: " & $PC_VertionExists ); Debug
;   MsgBox (0, "Test FileFindFirstFile", "This is a test of FileFindFirstFile: " & $slocalOldExists & $PC_VertionExists ) ; Debug

;    Chack the Java Version on the Clint Mchine
      If $iDownloadVersion == $PC_VertionExists or $slocalOldExists = -1 Then
         MsgBox (0, "Java is up to date", "You have the newest version of Java on your PC", 5)
         Return False
      Elseif $iDownloadVersion <> $PC_VertionExists or $slocalOldExists = 1 Then
         MsgBox (0, "Java Insallation - Information", "Downloading a new version of java will beginning" , 10)
;~       MsgBox (0, "Java Insallation - Information", "Insallation will continue" , 10)
         InetGet ("http://javadl.sun.com/webapps/download/AutoDL?BundleId=107944", "Java - Setup.exe", $INET_DOWNLOADWAIT )
         Local $Size = FileGetSize ( "Java - Setup.exe" ) ; Size of Download in order to check if everything Downloaded fine,

         If FileExists ( "Java - Setup.exe" ) = 1 And $Size > 4096 Then ; Check if the installtion downlaod successfully
            $PC_VertionExists = FileGetVersion($sLocalFile, $FV_PRODUCTVERSION) ; Test the $PC_VertionExists variabile (becuse if you have an Old version
            Local $iDownloadVersion = FileGetVersion ( "Java - Setup.exe" , $FV_PRODUCTVERSION ) ; $iDownloadVersion Check the version that stored in the ROOT dir of the script (the installtion)
            MsgBox ( 0, "File Exist", "Your file has been downloaded successfully,Installtion will start, Click OK to Continue")
         Else
            MsgBox ( 0, "Download Version - Error", "Java - Setup.exe not found, installtion will stop")
            Exit
            EndIf

         If $iDownloadVersion == $PC_VertionExists Then
            MsgBox ( 0, "Download Version - Information", "You Alrady have the newest version on you PC")
            Exit
            Else
;~       MsgBox (0, "New Java version as been Download","Installtion will start, Click OK to Continue" )
         ; this Code will install Java.exe with half user entercations
         ShellExecute ( "Java - Setup.exe" )
         WinWaitActive ( "Java Setup - Welcome" , "Change destination folder" )
         ControlClick (  "Java Setup - Welcome" , "Change destination folder" , 1 )

         WinWaitActive ( "Java Setup - Complete" , "You have successfully installed Java" )
         ControlClick (  "Java Setup - Complete" , "You have successfully installed Java" , 2 )
         EndIf
     EndIf

EndFunc

 

Edited by Orara
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...