ved230609 Posted August 6, 2015 Share Posted August 6, 2015 Hi, i am new to AutoIT and i am trying to write a script which will start java install and if java is installed then it should launch with the browser else it should start the installation. I am not getting what wrong i am doing...i am stuck...please help Run("c:\Temp\jdk-7u45-windows-x64.exe") if WinWaitActive("Java SE Development Kit 7 Update 45 (64-bit)", "reinstall it?") Then send("!n") Else WinWaitActive("Java SE Development Kit 7 Update 45 (64-bit) - Setup", "Welcome to the Installation") Send("!n") WinWaitActive("Java SE Development Kit 7 Update 45 (64-bit) - Custom Setup") Send("!n") WinWaitActive("Java Setup - Destination Folder", "Install to") send("!n") WinWaitActive("Java SE Development Kit 7 Update 45 (64-bit) - Complete") EndIf ; Java installation complete Send("{ENTER}") ; Make default plage blank ShellExecute("C:\Program Files\Internet Explorer\iexplore.exe", "about:blank") Link to comment Share on other sites More sharing options...
Developers Jos Posted August 6, 2015 Developers Share Posted August 6, 2015 You are waiting for this window so the script will stop there until this window appears.WinWaitActive("Java SE Development Kit 7 Update 45 (64-bit)", "reinstall it?")This is probably not the best approach but should demonstrate where you were going wrong: (UnTested)Run("c:\Temp\jdk-7u45-windows-x64.exe") While 1 If WinExists("Java SE Development Kit 7 Update 45 (64-bit)", "reinstall it?") _ or WinExists("Java SE Development Kit 7 Update 45 (64-bit) - Setup", "Welcome to the Installation") Then ExitLoop EndIf Sleep(100) WEnd If WinExists("Java SE Development Kit 7 Update 45 (64-bit)", "reinstall it?") Then Send("!n") Else Send("!n") WinWaitActive("Java SE Development Kit 7 Update 45 (64-bit) - Custom Setup") Send("!n") WinWaitActive("Java Setup - Destination Folder", "Install to") Send("!n") WinWaitActive("Java SE Development Kit 7 Update 45 (64-bit) - Complete") EndIf ; Java installation complete Send("{ENTER}") ; Make default plage blank ShellExecute("C:\Program Files\Internet Explorer\iexplore.exe", "about:blank")Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
ved230609 Posted August 6, 2015 Author Share Posted August 6, 2015 Thanks a lot Jos for your reply. however i am not waiting for that window. Below is the situation:if WinWaitActive("Java SE Development Kit 7 Update 45 (64-bit)", "reinstall it?") Then send("!n")if this is true then it opens browser and this is expected behavior.However if the java is not installed it comes to this window and is not sending the "!n"WinWaitActive("Java SE Development Kit 7 Update 45 (64-bit) - Setup", "Welcome to the Installation")Send("!n") i will also try your way and see how it goes Link to comment Share on other sites More sharing options...
Developers Jos Posted August 6, 2015 Developers Share Posted August 6, 2015 Maybe you need to wait a little for the Window to complete displaying before sending the "!n" and ensure the Window hasn't lost focus.You could do a WinActivate() to regain focus in case it lost it.Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
ved230609 Posted August 6, 2015 Author Share Posted August 6, 2015 i tried using sleep(2000) and then WinActivate() didn't help. I also tried the code that you gave previously but still same issue. Please help Link to comment Share on other sites More sharing options...
Developers Jos Posted August 6, 2015 Developers Share Posted August 6, 2015 Again ... as stated in my first post: Your logic is flawed as your script will get stuck on the first WinWaiActive() until that is true!That is why I posed the script in my reply to show you how you could work around that .. (Untested so can't promise it works with the installer you use)\Add this statement at the top of your script so you can see on which line your script hangs:Opt("TrayIconDebug", 1) ;0=no info, 1=debug line info.. and hover over the trayicon when it hangs.Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
ved230609 Posted August 6, 2015 Author Share Posted August 6, 2015 thanks Jos, i understand the flaw in my code and tried to follow the code you gave, when i try to run it it says that:"If" statements must have a "Then" keyword.:if WinExists("Java SE Development Kit 7 Update 45 (64-bit)", "reinstall it?")then i corrected to: if WinExists("Java SE Development Kit 7 Update 45 (64-bit)", "reinstall it?") Thenor WinExists() but still same issue, when i hover over tray icon it says Sleep(100)please help Link to comment Share on other sites More sharing options...
Developers Jos Posted August 6, 2015 Developers Share Posted August 6, 2015 You need to copy & paste everything! There is an underscore at the end of the If lineJos ved230609 1 SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
ViciousXUSMC Posted August 6, 2015 Share Posted August 6, 2015 Java is really easy to silent install, I usually use the .MSI files and set them up to turn off all the auto update junk. For the .exe just a /s should do the silent install. Link to comment Share on other sites More sharing options...
ved230609 Posted August 6, 2015 Author Share Posted August 6, 2015 thank a lot Jos, i finally got this working...@ViciousXUSMC, i would do that but i have to push this to 1000 users. Java install is just a start there are further more operations after this. Thanks a ton Jos Link to comment Share on other sites More sharing options...
Developers Jos Posted August 6, 2015 Developers Share Posted August 6, 2015 (edited) So normally when I really would need to do WinExists() & Send() depending on multiple possibilities I would do a loop like this in stead of what i posted earlier, but that was an effort to show your logic flaw: Run("c:\Temp\jdk-7u45-windows-x64.exe") While 1 If WinExists("Java SE Development Kit 7 Update 45 (64-bit)", "reinstall it?") Then Send("!n") ExitLoop EndIf If WinExists("Java SE Development Kit 7 Update 45 (64-bit) - Setup", "Welcome to the Installation") Then Send("!n") WinWaitActive("Java SE Development Kit 7 Update 45 (64-bit) - Custom Setup") Send("!n") WinWaitActive("Java Setup - Destination Folder", "Install to") Send("!n") WinWaitActive("Java SE Development Kit 7 Update 45 (64-bit) - Complete") ExitLoop EndIf Sleep(100) WEnd ; Java installation complete Send("{ENTER}") ; Make default plage blank ShellExecute("C:\Program Files\Internet Explorer\iexplore.exe", "about:blank")In this way you can add as many Window options and their actions as you want. P.S. I would prefer using ControlSend() when possible!Jos Edited August 6, 2015 by Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
ved230609 Posted August 6, 2015 Author Share Posted August 6, 2015 great thanks again Jos....your help very much appreciated Link to comment Share on other sites More sharing options...
SadBunny Posted August 7, 2015 Share Posted August 7, 2015 Just a heads-up... You'll have to change this code every time you want to implement a new update of a new version of java. You may want to change those titles to just look for the beginning of that string, so it is slightly more prepared for the future.Another thing you may want to consider is installing java directly (without installer), by simply placing the required files in a directory of your choice and setting the JAVA_HOME/PATH. That way you don't have to worry about installers at all.Just my $0.02. Roses are FF0000, violets are 0000FF... All my base are belong to you. Link to comment Share on other sites More sharing options...
ved230609 Posted August 7, 2015 Author Share Posted August 7, 2015 Thanks Sadbunny I am again stuck and not understanding what wrong i am doing in this. After WEnd, security information popup comes up and it should send !r but its not doing anything. when i hover in the task bar icon it says paused at sleep(100)....Please help Link to comment Share on other sites More sharing options...
ved230609 Posted August 7, 2015 Author Share Posted August 7, 2015 Thank you guys, i figured it out.....Thanks again for all your help Link to comment Share on other sites More sharing options...
Developers Jos Posted August 7, 2015 Developers Share Posted August 7, 2015 Just an FYI: No need to post Captures of your code, but simply copy&paste in in the Window you get when pressing <> in the tool bar of the editor.Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
ved230609 Posted August 19, 2015 Author Share Posted August 19, 2015 Thanks JosNeed one more help. I have a batch file where user select his location and depending on his location software installation starts from that server. i want that input from the user of his location to be the input to my autoit program...how to do that? Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now