Page 1 sur 1

AutoIt et déployer une application

Posté : jeu. 13 déc. 2018 15:05
par cedbuj
Bonjour,
j'utilise pour déployer des applications depuis un serveur vers des clients le module "Wpkg".
Pour ce faire, j'utilise des les installations silencieuses pour chacun des logiciels.

Or, je me heurte à un logiciel qui ne possède pas de paramètre d'installation silencieuse (OpenvisualTraceRoute qui contient également WinPcap).
Je me suis donc tourné vers AutoIt (je connais que très peu et je n'ai de formation informatique, autodidacte...)

J'ai commencé par un script très simple :
;Application nécéssitant les droits d'admin
#RequireAdmin
;Affiche en bas à droite un message informant de l'installation
TrayTip("Installation de Open Visual Trace route1.7.1","installation en cours",3000)

Run("OpenVisualTraceroute1.7.1.0.exe")
WinWaitActive("Setup - Open Visual Traceroute", "Welcome to the Open Visual Traceroute Setup Wizard")
Send("{ENTER}")
WinWaitActive("Setup - Open Visual Traceroute", "License Agreement")
Send("{TAB}")
Send("{Up}")
Send("{TAB}")
Send("{TAB}")
Send("{ENTER}")
WinWaitActive("Setup - Open Visual Traceroute", "Select Destination Location")
Send("{ENTER}")
WinWaitActive("Setup - Open Visual Traceroute", "Select Start Menu Folder")
Send("{ENTER}")
WinWaitActive("Setup - Open Visual Traceroute", "Select Additional Tasks")
Send("{ENTER}")
WinWaitActive("Setup - Open Visual Traceroute", "Ready to Install")
Send("{ENTER}")
WinWaitActive("Setup", "")
Send("{ENTER}")

;Affiche en bas à droite un message informant de l'installation de WinPcap
TrayTip("Installation de WinPcap 4.1.3","installation en cours",3000)

WinWaitActive("WinPcap 4.1.3 Setup", "Welcome to the WinPcap 4.1.3 Setup Wizard")
Send("{ENTER}")
WinWaitActive("WinPcap 4.1.3 Setup", "License Agreement")
Send("{ENTER}")
WinWaitActive("WinPcap 4.1.3 Setup", "Installation options")
Send("{ENTER}")
WinWaitActive("WinPcap 4.1.3 Setup", "Completing the WinPcap 4.1.3 Setup Wizard")
Send("{ENTER}")
WinWaitActive("Setup", "WinPcap installed successfully. Now installing Open Visual Traceroute")
Send("{ENTER}")

WinWaitActive("Setup - Open Visual Traceroute", "Completing the Open Visual Traceroute Setup Wizard")
Send("{SPACE}")
Send("{TAB}")
Send("{ENTER}")

;Affiche en bas à droite un message informant de la fin de l'installation
TrayTip("Installation de Open Visual Trace route1.7.1","Fin de l'installation",3000)
Mais, je me heurte à un problème : l'éxécution se fait en tâche de fond..

J'ai essayé ceci :
;Application nécéssitant les droits d'admin
#RequireAdmin
;Affiche en bas à droite un message informant de l'installation
TrayTip("Installation de Open Visual Trace route1.7.1","installation en cours",3000)

Run("OpenVisualTraceroute1.7.1.0.exe")
sleep(25)

WinWaitActive("Setup - Open Visual Traceroute", "Welcome to the Open Visual Traceroute Setup Wizard")
If winactive("Setup - Open Visual Traceroute", "Welcome to the Open Visual Traceroute Setup Wizard") Then
 Send("{ENTER}")
EndIf

WinWaitActive("Setup - Open Visual Traceroute", "License Agreement")
If WinExists("Setup - Open Visual Traceroute", "License Agreement") Then
 Send("{TAB}")
 Send("{Up}")
 Send("{TAB}")
 Send("{TAB}")
 Send("{ENTER}")
EndIf

WinWaitActive("Setup - Open Visual Traceroute", "Select Destination Location")
If WinExists("Setup - Open Visual Traceroute", "Select Destination Location") Then
 Send("{ENTER}")
EndIf

WinWaitActive("Setup - Open Visual Traceroute", "Select Start Menu Folder")
If WinExists("Setup - Open Visual Traceroute", "Select Start Menu Folder") Then
 Send("{ENTER}")
EndIf

WinWaitActive("Setup - Open Visual Traceroute", "Select Additional Tasks")
If WinExists("Setup - Open Visual Traceroute", "Select Additional Tasks") Then
 Send("{ENTER}")
EndIf

WinWaitActive("Setup - Open Visual Traceroute", "Ready to Install")
If WinExists("Setup - Open Visual Traceroute", "Ready to Install") Then
 Send("{ENTER}")
EndIf

sleep(10)

If WinExists("Setup", "") Then
 Send("{ENTER}")
EndIf

WinWaitActive("WinPcap 4.1.3 Setup", "")
If WinExists("WinPcap 4.1.3 Setup", "") Then
 Send("{ENTER}")
EndIf

sleep(5)

WinWaitActive("WinPcap 4.1.3 Setup", "Welcome to the WinPcap 4.1.3 Setup Wizard")
If WinExists("WinPcap 4.1.3 Setup", "Welcome to the WinPcap 4.1.3 Setup Wizard") Then
 Send("{ENTER}")
EndIf

WinWaitActive("WinPcap 4.1.3 Setup", "License Agreement")
If WinExists("WinPcap 4.1.3 Setup", "License Agreement") Then
 Send("{ENTER}")
EndIf

WinWaitActive("WinPcap 4.1.3 Setup", "Installation options")
If WinExists("WinPcap 4.1.3 Setup", "Installation options") Then
    Send("{TAB}")
    Send("{TAB}")
    Send("{ENTER}")
EndIf

WinWaitActive("WinPcap 4.1.3 Setup", "Completing the WinPcap 4.1.3 Setup Wizard")
If WinExists("WinPcap 4.1.3 Setup", "Completing the WinPcap 4.1.3 Setup Wizard") Then
 Send("{ENTER}")
EndIf

WinWaitActive("Setup", "WinPcap installed successfully. Now installing Open Visual Traceroute")
If WinExists("Setup", "WinPcap installed successfully. Now installing Open Visual Traceroute") Then
 Send("{ENTER}")
EndIf

WinWaitActive("Setup - Open Visual Traceroute", "Completing the Open Visual Traceroute Setup Wizard")
If WinExists("Setup - Open Visual Traceroute", "Completing the Open Visual Traceroute Setup Wizard") Then
 Send("{SPACE}")
 Send("{TAB}")
 Send("{ENTER}")
EndIf


 ;Affiche en bas à droite un message informant de la fin de l'installation
TrayTip("Installation de Open Visual Trace route1.7.1","Fin de l'installation",3000)
Cela ne fonctionne pas aussi en tâche de fond...

Je sollicite donc votre aide...

Merci

Re: AutoIt et déployer une application

Posté : jeu. 13 déc. 2018 18:18
par walkson
Bonjour,
Il semble que ce logiciel possède une version portable (voir https://sourceforge.net/projects/openvi ... les/1.7.1/ extension ZIP)
Dans ce cas, vous pouvez le dézipper avec 7zip par exemple (voir les UDF récents 7zip pour manœuvrer avec Autoit relativement facilement)
Sinon, pour une installation en "dur", cherchez Control dans l'aide pour voir toutes les possibilités.
A priori, c'est ControlClick() que vous devriez avoir besoin. Par exemple
ControlClick("Setup - Open Visual Traceroute", "", "[CLASS:Button; INSTANCE:1]") mais il y a aussi ControlCommand()
Pour attendre l'ouverture d'une fenêtre, on peut utiliser Sleep() ou utilisez une boucle. Par exemple:
While 1
If winactive("Setup - Open Visual Traceroute", "") Then
ControlClick("Setup - Open Visual Traceroute", "", "[CLASS:Button; INSTANCE:1]")
ExitLoop
EndIf
Wend
Il y a l'outil Window info qui permet de retrouver les class ou les ClassnameNN et autres (glissez le cercle sur fond blanc sur le control).
La seule solution à votre problème est de tester et d'être patient :wink:

RMQ: il semble aussi que Java doit être installé "The software is written in Java and runs on Windows, MacOS X, Ubuntu, OpenSUSE."

Re: AutoIt et déployer une application

Posté : jeu. 13 déc. 2018 19:12
par mikell
En cas d'utilisation massive de ControlSend (nettement préférable à Send) ou ControlClick je conseillerais peut-être l'association avec BlockInput pour éviter d'éventuelles interférences causées par des actions aléatoires de l'interface chaise-clavier

Image

Re: AutoIt et déployer une application

Posté : ven. 14 déc. 2018 08:32
par cedbuj
Bonjour,
merci pour la réponse.
Il y a effectivement une version portable mais le problème reste identique car OpenVisual Trace Route nécessite l'installation de WinPcap qui n'a pas lui aussi la possibilité d'une installation silencieuse. Et lors de l'installation de Visual Open Trace route, WinPcap est installé automatiquement (le même installateur que pour une installation indépendante). Donc, je suis resté sur la version non portable...
Java est déployé automatiquement...

Je vais donc me pencher sur ControlClick..

Merci

Re: AutoIt et déployer une application

Posté : ven. 14 déc. 2018 14:49
par cedbuj
J'ai donc modifié comme ceci
Run("OpenVisualTraceroute1.7.1.0.exe")

While 1
If winactive("Setup - Open Visual Traceroute", "Welcome to the Open Visual Traceroute Setup Wizard") Then
ControlClick("Setup - Open Visual Traceroute", "Welcome to the Open Visual Traceroute Setup Wizard", "[CLASS:TNewButton; INSTANCE:1]")
ExitLoop
EndIf
Wend

While 2
If winactive("Setup - Open Visual Traceroute", "License Agreement") Then
ControlClick("Setup - Open Visual Traceroute", "License Agreement", "[CLASS:TNewRadioButton; INSTANCE:1]")
ControlClick("Setup - Open Visual Traceroute", "License Agreement", "[CLASS:TNewButton; INSTANCE:2]")
ExitLoop
EndIf
Wend

While 3
If winactive("Setup - Open Visual Traceroute", "Select Destination Location") Then
ControlClick("Setup - Open Visual Traceroute", "Select Destination Location", "[CLASS:TNewButton; INSTANCE:3]")
ExitLoop
EndIf
Wend

While 4
If winactive("Setup - Open Visual Traceroute", "Select Start Menu Folder") Then
ControlClick("Setup - Open Visual Traceroute", "Select Start Menu Folder", "[CLASS:TNewButton; INSTANCE:4]")
ExitLoop
EndIf
Wend

While 5
If winactive("Setup - Open Visual Traceroute", "Select Additional Tasks") Then
ControlClick("Setup - Open Visual Traceroute", "Select Additional Tasks", "[CLASS:TNewButton; INSTANCE:4]")
ExitLoop
EndIf
Wend

While 6
If winactive("Setup - Open Visual Traceroute", "Ready to Install") Then
ControlClick("Setup - Open Visual Traceroute", "Ready to Install", "[CLASS:TNewButton; INSTANCE:4]")
ExitLoop
EndIf
Wend

While 7
If winactive("Setup", "OK") Then
ControlClick("Setup", "OK", "[CLASS:Button; INSTANCE:1]")
ExitLoop
EndIf
Wend

While 8
If winactive("Setup - Open Visual Traceroute", "") Then
ControlClick("Setup - Open Visual Traceroute", "", "[CLASS:TNewButton; INSTANCE:1]")
ExitLoop
EndIf
Wend

While 9
If winactive("WinPcap 4.1.3 Setup", "") Then
ControlClick("WinPcap 4.1.3 Setup", "", "[CLASS:Button; INSTANCE:1]")
ExitLoop
EndIf
Wend

While 10
If winactive("WinPcap 4.1.3 Setup", "Welcome to the WinPcap 4.1.3 Setup Wizard") Then
ControlClick("WinPcap 4.1.3 Setup", "Welcome to the WinPcap 4.1.3 Setup Wizard", "[CLASS:Button; INSTANCE:2]")
ExitLoop
EndIf
Wend

While 11
If winactive("WinPcap 4.1.3 Setup", "License Agreement") Then
ControlClick("WinPcap 4.1.3 Setup", "License Agreement", "[CLASS:Button; INSTANCE:2]")
ExitLoop
EndIf
Wend

While 12
If winactive("WinPcap 4.1.3 Setup", "Installation options") Then
ControlClick("WinPcap 4.1.3 Setup", "Installation options", "[CLASS:Button; INSTANCE:2]")
ExitLoop
EndIf
Wend

While 13
If winactive("WinPcap 4.1.3 Setup", "Completing the WinPcap 4.1.3 Setup Wizard") Then
ControlClick("WinPcap 4.1.3 Setup", "Completing the WinPcap 4.1.3 Setup Wizard", "[CLASS:Button; INSTANCE:2]")
ExitLoop
EndIf
Wend

While 14
If winactive("Setup", "WinPcap installed successfully. Now installing Open Visual Traceroute") Then
ControlClick("Setup", "WinPcap installed successfully. Now installing Open Visual Traceroute", "[CLASS:Button; INSTANCE:1]")
ExitLoop
EndIf
Wend

While 14
If winactive("Setup - Open Visual Traceroute", "Completing the Open Visual Traceroute Setup Wizard") Then
ControlClick("Setup - Open Visual Traceroute", "Completing the Open Visual Traceroute Setup Wizard", "[CLASS:TNewCheckListBox; INSTANCE:1]", "left", 1, 8, 9)
ControlClick("Setup - Open Visual Traceroute", "Completing the Open Visual Traceroute Setup Wizard", "[CLASS:TNewButton; INSTANCE:4]")
ExitLoop
EndIf
Wend
Mais, je me heurte toujours au même problème : en tâche de fond, cela ne marche pas...
si je clique directement sur mon exécutable, pas de problème..

J'appelle mon exécutable à l'aide d'un XML:
<?xml version="1.0" encoding="UTF-8"?>
<packages>

<package id="OpenVisualTraceroute"
         name="Open Visual Traceroute"
         revision="1.7.1.0"
         reboot="false"
         priority="5">
<depends package-id="jre"/>      
   
   <!--   -->
     
  <!--  Dézipper, je ne sais faire avec le xml pour le moment -->
   
   <variable name="PROGRAMFILES" value="%PROGRAMFILES%" architecture="x86"/>
   <variable name="PROGRAMFILES" value="%PROGRAMFILES% (x86)" architecture="x64"/>
   <variable name="ComSpec" value="%SystemRoot%\System32\cmd.exe" architecture="x86"/>
   <variable name="ComSpec" value="%SystemRoot%\SysWOW64\cmd.exe" architecture="x64"/>
         
   <check type="logical" condition="and">
       <check type="uninstall" condition="exists" path="WinPcap 4.1.3" />
      <check type="uninstall" condition="exists" path="Open Visual Traceroute version 1.7.1" />
      </check>
     
   <!-- copier le répertoire d'installation à la racine du poste -->
   <install cmd='
xcopy  /E /F /R /Q /Z /Y "%Z%\packages\OpenVisualTraceroute" "%SystemDrive%\OpenVisualTraceroute\"'>
       <exit code='
any'/>
   </install>
   <!-- installation -->
   <install cmd='
%ComSpec% /C "%SystemDrive%\OpenVisualTraceroute\Silent_Install_OpenVisualTraceRoute_1.7.1.exe"'>
       <exit code='
any'/>
   </install>        
   <!--  Suppression du répertoire d'
installation à la racine du poste -->
   <install cmd='%ComSpec% /C if exist "%SystemDrive%\OpenVisualTraceroute\" rd /S /Q "%SystemDrive%\OpenVisualTraceroute\"'>
       <exit code='any'/>
   </install>
     
     
   <upgrade include="install" />
   <downgrade include="upgrade" />
   
    <remove cmd='"%ProgramFiles%\WinPcap\Uninstall.exe" /S' />
    <remove cmd='"%ProgramFiles%\Open Visual Traceroute\unins000.exe" /S' />
 
 
   </package