Page 1 sur 1

peut on insérer du batch dans autoit ?

Posté : jeu. 29 juil. 2021 16:28
par deuval
Bonjour,

Je souhaite faire un lanceur avec des checkboxs, pour remplacer un vieux .bat qui demandait pour tous les logiciels si oui ou non on voulait l'installer. J'ai parcouru le forum j'ai pu faire ceci :
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
Global $Form1 = GUICreate("Form1", 361, 345, 299, 210)
Global $Group1 = GUICtrlCreateGroup("Logiciels", 80, 48, 201, 265)
Global $CHK_powerpoint = GUICtrlCreateCheckbox("Powerpoint OneNote ", 120, 88, 129, 25)
Global $CHK_notepad = GUICtrlCreateCheckbox("notepad", 120, 120, 97, 17)
Global $CHK_filezilla = GUICtrlCreateCheckbox("Filezilla", 120, 152, 97, 17)
Global $Checkbox4 = GUICtrlCreateCheckbox("Checkbox4", 120, 184, 97, 17)
Global $Checkbox5 = GUICtrlCreateCheckbox("Checkbox5", 120, 216, 97, 17)
Global $BTN_installer = GUICtrlCreateButton("Installer", 144, 256, 75, 25)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
 $nMsg = GUIGetMsg()
 Switch $nMsg
  Case $GUI_EVENT_CLOSE
   Exit
    Case $BTN_installer
       _DoInstallation()
 EndSwitch
WEnd

Func _DoInstallation()
   If GUICtrlRead($CHK_powerpoint)=$GUI_CHECKED Then
                RunWait(@COMSPEC & " /k \\serveur\powerpoint\install.exe /SP- /VERYSILENT /SUPPRESSMSGBOXES /NORESTART /LOG=C:\installpower.txt")
      Sleep(500)
   EndIf
   If GUICtrlRead($CHK_notepad)=$GUI_CHECKED Then
        RunAswait ( "admin", "MonDomaine", "MonPWD", 0, "cscript \\LeServeur\Appli\InstallNotepad.bat //b"  )
      Sleep(500)
   EndIf
   If GUICtrlRead($CHK_filezilla)=$GUI_CHECKED Then
        RunAswait ( "admin", "MonDomaine", "MonPWD", 0, "cscript \\LeServeur\Appli\InstallFilezilla.bat //b"  )
      Sleep(500)
   EndIf
EndFunc
pour notre powerpoint c'est assez simple puisque c'est qu'une ligne de batch. Je suppose que je peux le lancer avec un runwait. Mais lorsque l'installation demande plusieurs ligne, comment je dois faire ? est ce que je dois forcement isoler le code dans un autre .bat ? ou il y a un autre moyen ?

J'aimerai voir l'invite de commande, ou plutot ce qu'il s'y passe à l’intérieur. Peut on intégrer ça a auto it ? dans un textarea par exemple ?

Re: peut on insérer du batch dans autoit ?

Posté : ven. 30 juil. 2021 09:38
par rgx
Bonjour,

Plusieurs solutions:
  • On peut appeler un batch (.bat ou .cmd)
  • On peut grouper plusieurs commandes sur une ligne (fonctionnalité standard du shell) avec
    • commande1 & Commande2 : L'une après l'autre
    • commande1 && Commande2 : Pareil, mais commande2 ne s'exécute que si Commande 1 est OK
    • commande1 || Commande2 : Pareil, mais commande2 ne s'exécute que si Commande 1 est KO
    • On peut grouper des actions avec des ()
Avec /K, la fenêtre reste ouverte tant que le batch se déroule
(on peut ajouter exit pour sortir)