Jump to content

like? transform this code to autoit


chelo32
 Share

Recommended Posts

I would like to tranform this code I found on the web autoit
It is written in batch, and the truth is very good and practical
If anyone has any idea I leave the code
Sorry for my bad English

@echo off
setlocal enableextensions enabledelayedexpansion
color 17
title Java removal/update tool v0.9

echo.
echo This software is brought to you by Grintor.
echo ^<Grintor at Gmail dot Com^>
echo.
echo This program is free software.
echo This program IS PROVIDED WITHOUT WARRANTY, EITHER EXPRESSED OR IMPLIED.
echo This program is copyrighted under the terms of GPLv3:
echo see ^<http://www.gnu.org/licenses/^>.
echo.
echo This program uses cURL, also free software, source code available:
echo see ^<http://curl.haxx.se/^>.
echo.
echo This binary is also a compressed package.
echo The source code is available within.
echo It can be decompressed using 7-zip, also free software:
echo see ^<http://www.7-zip.org/^>.
echo.

FOR /L %%n IN (1,1,10) DO ping -n 2 127.0.0.1 > nul & <nul set /p =.

cls
echo.
echo Searching for latest version of Java...
ping -n 1 google.com > nul || goto error


::----------- Find the latest java version----------------------------------
FOR /F "tokens=2 delims=<> " %%n IN ('curl.exe -s -L http://javadl-esd.sun.com/update/1.7.0/map-m-1.7.0.xml ^| find /i "https:"') DO set URL1=%%n
FOR /F "tokens=2 delims=<> " %%n IN ('curl.exe -s -L -k %URL1% ^| find /i "<version>"') DO set RemoteJavaVersion=%%n
set RemoteJavaVersion=%RemoteJavaVersion:~0,8%
echo The latest version of java is %RemoteJavaVersion%.




::----------- Find the local Java version-----------------------------------
set LocalJavaVersion=None
FOR /F "tokens=1-15" %%n IN ('reg query HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall /s ^& reg query HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall /s 2^> nul') DO (

   if '%%n'=='InstallSource' (
     set p=%%p%%q%%r%%s%%t%%u%%v%%w%%x%%y%%z
     set p=!p: =\!
     set p=!p:\= !
     for %%n in (!p!) do set c=%%n
   )

   if '%%n'=='DisplayName' (
      set p=%%p
      if "!p:~0,4!"=="Java" if not "%%q"=="Auto" if not '!LocalJavaVersion!'=='None' (set LocalJavaVersion=Multi) ELSE (set LocalJavaVersion=!c:~3!)
      if "!p:~0,4!"=="J2SE" if not '!LocalJavaVersion!'=='None' (set LocalJavaVersion=Multi) ELSE (set LocalJavaVersion=!c:~3!)
   )
)

if '%LocalJavaVersion%'=='None' echo There is no local version of Java. & goto install
if '%LocalJavaVersion%'=='Multi' echo There are multiple local versions of Java installed. & goto uninstall
echo The local version of Java is %LocalJavaVersion%.




::----------- If they match, skip to the end---------------------------------
if '%RemoteJavaVersion%'=='%LocalJavaVersion%' (goto finished) ELSE (echo The Local version of Java is out of date.)




::----------- Uninstall all currently installed java versions----------------
:uninstall
if '%LocalJavaVersion%'=='Multi' (echo Uninstalling all local versions of Java...) ELSE (echo Uninstalling the local version of Java...)
FOR /F "tokens=1-4" %%n IN ('reg query HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall /s ^& reg query HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall /s 2^> nul') DO (

   if '%%n'=='UninstallString' (
     set c=%%q
     set c=!c:/I=/X!
   )

   if '%%n'=='DisplayName' (
      set d=%%p
      if "!d:~0,4!"=="Java" if not "%%q"=="Auto" msiexec.exe !c! /qn & ping -n 11 127.0.0.1 > nul
      if "!d:~0,4!"=="J2SE" msiexec.exe !c! /qn & ping -n 11 127.0.0.1 > nul
   )
)



::----------- Download the latest java, install, delete the installer.-------
:install
echo Downloading latest version of Java...
FOR /F "tokens=2 delims=<> " %%n IN ('curl.exe -s -L -k %url1% ^| find /i ".exe"') DO set url2=%%n
curl.exe -s -L -k -o java.exe %url2%
echo Installing latest version of Java...
start /wait java.exe /s
ping 127.0.0.1 > nul
del java.exe



::----------- Up to date ----------------------------------------------------
:finished
echo Your Java is up to date.
echo.


::----------- There was an error---------------------------------------------
goto noerror
:error
echo There was a network error. Please try again.
:noerror


FOR /L %%n IN (1,1,10) DO ping -n 2 127.0.0.1 > nul & <nul set /p =.

http://downloads.sourceforge.net/project/autojavaupdater/java%20tool.exe?r=http%3A%2F%2Fsourceforge.net%2Fprojects%2Fautojavaupdater%2F&ts=1385042371&use_mirror=ufpr

Link to comment
Share on other sites

  • Moderators

It looks very doable in autoit. But what have you tried yourself? This is not a forum where you tell people what you want and we barf up code for you, you have to show a little effort ;)

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

LOL 

 

 we barf up code 

 

    :x

~~~~~~

aawww didn't that icon used to actually barf?

Edit:  

   :puke:

~~~~~~

There ya gewww...    (cartman's voice)

Edited by billo
Link to comment
Share on other sites

  • Moderators

billo,

You mean like this: :D

:puke:

M23

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

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

you can find installed versions of java for 32bit windows 7 here.  Google for the 64 bits one

HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Runtime Environment

use this command to return the full path to all instances of javaw.exe on your machine. note that it's only recursively searching below the current directory so start it in the root of the drive you're searching

dir /s /b java.exe

this runs fast on my machine.  two instances of java.exe returned and the search took about a second on an ssd

you can run the returned executable with the -v switch to get the version number for that instance.

this should be enough basic tools to do the job.

there's a much easier way to do it though, use NiNite and it'll check for updates, download and install without the optional rapeware being installed. Just lives as a single exe on your machine.  Makes my life easy as it updates 90% of the apps I use everyday with a single click of a single executable file, no installation required.

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...