Jump to content

how to automate Java Installer


Recommended Posts

Look for unatentded instalation switches

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

Thank you dear
although i have found this solution 
like this 
first i have to record it's state 

jdk-8u101-nb-8_1-windows-x64.exe --record state.xml

then i can use like this 

jdk-8u101-nb-8_1-windows-x64.exe --silent --state state.xml

Or 
 

<?xml version="1.0" encoding="UTF-8"?><!--
  DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.

  Copyright 1997-2010 Oracle and/or its affiliates. All rights reserved.

  Oracle and Java are registered trademarks of Oracle and/or its affiliates.
  Other names may be trademarks of their respective owners.

  The contents of this file are subject to the terms of either the GNU General Public
  License Version 2 only ("GPL") or the Common Development and Distribution
  License("CDDL") (collectively, the "License"). You may not use this file except in
  compliance with the License. You can obtain a copy of the License at
  http://www.netbeans.org/cddl-gplv2.html or nbbuild/licenses/CDDL-GPL-2-CP. See the
  License for the specific language governing permissions and limitations under the
  License.  When distributing the software, include this License Header Notice in
  each file and include the License file at nbbuild/licenses/CDDL-GPL-2-CP.  Oracle
  designates this particular file as subject to the "Classpath" exception as provided
  by Oracle in the GPL Version 2 section of the License file that accompanied this code.
  If applicable, add the following below the License Header, with the fields enclosed
  by brackets [] replaced by your own identifying information:
  "Portions Copyrighted [year] [name of copyright owner]"
  
  Contributor(s):
  
  The Original Software is NetBeans. The Initial Developer of the Original Software
  is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun Microsystems, Inc. All
  Rights Reserved.
  
  If you wish your version of this file to be governed by only the CDDL or only the
  GPL Version 2, indicate your decision by adding "[Contributor] elects to include
  this software in this distribution under the [CDDL or GPL Version 2] license." If
  you do not indicate a single choice of license, a recipient has the option to
  distribute your version of this file under either the CDDL, the GPL Version 2 or
  to extend the choice of license to its licensees as provided above. However, if you
  add GPL Version 2 code and therefore, elected the GPL Version 2 license, then the
  option applies only if the new code is made subject to such option by the copyright
  holder.
--><state xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="state-file.xsd">
<components>
        <product platform="windows linux solaris-sparc solaris-x86 macosx-ppc macosx-x86" status="to-be-installed" uid="nb-base" version="8.1.0.0.201510222201">
            <properties>
                <property name="installation.location.windows">C:\Program Files\NetBeans 8.1</property>
                <property name="minimum.jdk.version">1.7.0</property>
                <property name="jdk.location">C:\Program Files\Java\jdk1.8.0_101</property>
                <property name="installation.timestamp">1476539814627</property>
                <property name="start.menu.shortcut.location">all.users</property>
                <property name="installation.location.macosx">$N{install}/NetBeans/NetBeans 8.1.app</property>
                <property name="installation.location">$N{install}/netbeans-8.1</property>
                <property name="desktop.shortcut.location">all.users</property>
                <property name="netbeans.summary.message.text"/>
            </properties>
        </product>
        <product platform="windows-x64" status="to-be-installed" uid="jdk" version="1.8.0.101.1364">
            <properties>
                <property name="jdk.win.installed">true</property>
                <property name="jre.win.installed">true</property>
                <property name="installation.location">$N{install}/jdk1.8.0_101</property>
                <property name="javadb.win.installed">true</property>
                <property name="installation.location.windows">C:\Program Files\Java\jdk1.8.0_101</property>
            </properties>
        </product>
        <product platform="windows linux solaris-sparc solaris-x86 macosx-ppc macosx-x86" status="to-be-installed" uid="nb-extide" version="8.1.0.0.201510222201">
            <properties>
                <property name="show-in-wizard">false</property>
                <property name="installation.location">C:\Program Files\NetBeans 8.1</property>
            </properties>
        </product>
        <product platform="windows linux solaris-sparc solaris-x86 macosx-ppc macosx-x86" status="to-be-installed" uid="nb-javase" version="8.1.0.0.201510222201">
            <properties>
                <property name="jre.allowed">false</property>
                <property name="installation.location">C:\Program Files\NetBeans 8.1</property>
            </properties>
        </product>
    </components>
</state>

But as you know the packege that i have downloaded has JDK/JRE netbeans so it can take too much time for installation.
And a user who don't know much about these things he would be thinking what is going on :P 
so that is way i was thinking to make installer like a normal user install like autoit help contain a example winzip installation :D 
but thank you for reply :D :)

Link to comment
Share on other sites

Did you try JABSimple.Spy on my W10 this works see below on javacpl what is the output of first few lines?

F:\Program Files\Java\jre1.8.0_102
We are using X64 at cpu X64 Autoit 64 bit version 1
  Windows accessbridge 32 opened 1
 0 initializeAccessBridge is finishedWindows_run passed :
+>20:20:53 Starting AutoIt3Wrapper v.14.801.2025.0 SciTE v.3.4.4.0   Keyboard:00020409  OS:WIN_81/  CPU:X64 OS:X64    Environment(Language:0413)
+>         SciTEDir => C:\Program Files (x86)\AutoIt3\SciTE   UserDir => \AppData\Local\AutoIt v3\SciTE\AutoIt3Wrapper   SCITE_USERHOME => \AppData\Local\AutoIt v3\SciTE 
>Running AU3Check (3.3.14.2)  from:C:\Program Files (x86)\AutoIt3  input:\Documents\UIA\JABSimpleSpy.au3
+>20:20:54 AU3Check ended.rc:0
>Running:(3.3.14.2):C:\Program Files (x86)\AutoIt3\autoit3_x64.exe "\Documents\UIA\JABSimpleSpy.au3"    
--> Press Ctrl+Alt+Break to Restart or Ctrl+Break to Stop
F:\Program Files\Java\jre1.8.0_102
We are using X64 at cpu X64 Autoit 64 bit version 1
  Windows accessbridge 32 opened 1
 0 initializeAccessBridge is finishedWindows_run passed :
0hello  name: <Settings...>
  description: <<html>Modify settings for temporary files</html>>
  role: <push button>
  role_en_US: <push button>
  states: <enabled,focusable,visible,showing,opaque>
  states_en_US: <enabled,focusable,visible,showing,opaque>
  indexInParent: <0>
  childrenCount: <0>
  x: <1028>
  y: <447>
  width: <83>
  height: <0>
0hello  name: <Security>
  description: <>
  role: <page tab>
  role_en_US: <page tab>
  states: <enabled,focusable,visible,showing,focused,selectable>
  states_en_US: <enabled,focusable,visible,showing,focused,selectable>
  indexInParent: <3>
  childrenCount: <1>
  x: <827>
  y: <197>
  width: <50>
  height: <0>

 

 

Link to comment
Share on other sites

may be i am not using it in right way 
but when i run this was the output 

--> Press Ctrl+Alt+Break to Restart or Ctrl+Break to Stop
C:\Program Files\Java\jre1.8.0_111
We are using X64 at cpu X64 Autoit 64 bit version 1
  Windows accessbridge 32 opened 1
 0 initializeAccessBridge is finishedWindows_run passed :

And on press ctrl + w while mouse was on jdk-8u101-nb-8_1-windows-x64.exe Installer, It returns nothing 
not any thing in Scite output window or not even in Simple UIA Spy Editbox  (Or may be empty response)

Link to comment
Share on other sites

using controlclick is very not the correct way to install software, it's not very reliable.

Instead use java's silent switch / parameter, to automatic silently install it:

FileGetShortName(@UserProfileDir & "\java.exe /s")

 

I wrote a little function to obtain the link to the latest java version:'

(i'm using psexec to run the java installation as the system user. you may ask why. It's because we are using software restrictions, so to bypass them, I run it as the system account.

;Download and install latest java version


install_latest_java_version()

func install_latest_java_version()
SplashTextOn("Opdater Java", "Vent venligst" & @CRLF & @CRLF & "Installere Java: " & @CRLF & @CRLF & latest_java_version(), -1, -1, -1, -1, "", "", 24)
if FileExists(@UserProfileDir & "\java.exe") then FileDelete(@UserProfileDir & "\java.exe") ;makes sure we gets the

$readtext = InetRead("https://java.com/inc/BrowserRedirect1.jsp?locale=en",1)
$source = BinaryToString($readtext)
$text =  _StringBetween($source,'<a title="Download Java software for Windows Offline" href="', '">')
$latest_version = $text[0]

InetGet($latest_version, @UserProfileDir & "\java.exe")
;RunWait(@UserProfileDir & "\java.exe /s")

_RunDos(FileGetShortName(@UserProfileDir & "\PsExec.exe") & " -i -s /accepteula " & FileGetShortName(@UserProfileDir & "\java.exe /s"))

SplashOff()
EndFunc

;---------------------------------------------------------------------------------------------------------------------------------

;Get the name of latest java version

func latest_java_version()
if FileExists(@UserProfileDir & "\java.exe") then FileDelete(@UserProfileDir & "\java.exe") ;makes sure we gets the

$readtext = InetRead("https://java.com/inc/BrowserRedirect1.jsp?locale=en",1)
$source = BinaryToString($readtext)
$text =  _StringBetween($source,'<h4 class="sub">Recommended ', '</h4>')
$latest_version = $text[0]
Return($latest_version)
EndFunc

 

Edited by legend
Link to comment
Share on other sites

  • 4 months later...

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

×
×
  • Create New...