Je suis en 1ère année de BTS IRIS, et dans le cadre de mon projet de stage en entreprise, j'ai à réaliser un utilitaire de maintenance informatique comprennant les outils classiques tels que CCleaner etc sous AutoIt, langage que je ne manipule que depuis 2 jours, et que j'aime bien d'ailleurs
Mais là n'est pas la question, mon tuteur m'a fournit quelques scripts en batch à appliquer dans mon code AutoIt, or il s'avère que ceux-ci me posent problème.
A savoir, je dois adapter ce type de cmd DOS à mon script :
Code : Tout sélectionner
echo o|chkdsk %variable% /f► Afficher le texte
Code : Tout sélectionner
$disque=InputBox("SoClean" , "Quel disque voulez vous examinez ?")
;divers .exe lancés,, nous arrivont au batch
;la première ligne ici avec $disque
RunWait(@ComSpec & ' /c echo o | chkdsk $disque /f', '')
;les suivantes en test avec C:
RunWait(@COMSPEC & '/c rd /s /q C:\windows\temp')
RunWait(@COMSPEC & '/c rd /s /q C:\windows\ie7')
RunWait(@COMSPEC & '/c rd /s /q C:\windows\ie7updates')
RunWait(@COMSPEC & '/c rd /s /q C:\windows\ie8')
RunWait(@COMSPEC & '/c rd /s /q C:\windows\ie8updates')
RunWait(@COMSPEC & '/c rd /s /q ' & @ProgramFilesDir & '\Adobe\Reader 9.0\Setup Files')
Alors mes questions :
- comment écrire une commande dos en autoit, syntaxiquement correcte? Bien qu'ayant lu une grande partie du forum concernant cela, je n'y parviens toujours pas. ( on est vendredi
- comment introduire ma variable disque de manière à remplacer mon C:?
Mon code source pour les interessés :
► Afficher le texte
#cs ----------------------------------------------------------------------------
AutoIt Version : 3.3.6.0
Auteur:
Fonction du Script : Utilitaire de Maintenance Informatique
Modèle de Script AutoIt.
#ce ----------------------------------------------------------------------------
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
;-------------------------------------------------------------------------------
;-----------------------------INTERFACE-----------------------------------------
;-------------------------------------------------------------------------------
#Region ### START Koda GUI section ### Form=
Global $Form2 = GUICreate("Interface 1", 700,400, 302, 218)
;-------------------------------------------------------------------------------
;-----------------------------PARTIE NETTOYAGE----------------------------------
;-------------------------------------------------------------------------------
Global $Checkbox1 = GUICtrlCreateCheckbox("MAJ Java", 50, 56, 97, 17)
Global $Checkbox2 = GUICtrlCreateCheckbox("CCleaner", 50, 76, 97, 17)
Global $Checkbox3 = GUICtrlCreateCheckbox("Quick clean", 50, 96, 97, 17)
Global $Checkbox4 = GUICtrlCreateCheckbox("KCleaner", 50, 116, 97, 17)
Global $Checkbox5 = GUICtrlCreateCheckbox("GUP", 50, 136, 97, 17)
Global $Checkbox6 = GUICtrlCreateCheckbox("Javara", 50, 156, 97, 17)
Global $Checkbox7 = GUICtrlCreateCheckbox("Wise Disk Cleaner", 50, 176, 105, 17)
Global $Button1 = GUICtrlCreateButton("Nettoyage", 50, 200, 75, 25, $WS_GROUP)
;-------------------------------------------------------------------------------
;-----------------------------PARTIE SPYWARES-----------------------------------
;-------------------------------------------------------------------------------
Global $Checkbox8 = GUICtrlCreateCheckbox("conficker", 190, 56, 97, 17)
Global $Checkbox9 = GUICtrlCreateCheckbox("Malwares Bytes", 190, 76, 97, 17)
Global $Checkbox10 = GUICtrlCreateCheckbox("Norman", 190, 96, 97, 17)
Global $Checkbox11 = GUICtrlCreateCheckbox("Spybot S and D", 190, 116, 97, 17)
Global $Checkbox12 = GUICtrlCreateCheckbox("RAC", 190,136,97,17)
Global $Checkbox13 = GUICtrlCreateCheckbox("RFA", 190 , 156, 97, 17)
Global $Checkbox14 = GUICtrlCreateCheckbox("Super anti spyware" , 190 , 176 , 107 ,17 )
Global $Button2 = GUICtrlCreateButton("Spyware", 190, 200, 75, 25, $WS_GROUP)
;-------------------------------------------------------------------------------
;-----------------------------PARTIE DEFRAGMENTATION----------------------------
;-------------------------------------------------------------------------------
Global $Checkbox15 = GUICtrlCreateCheckbox("PagDeFrag" , 330,56,97,17)
Global $Checkbox16 = GUICtrlCreateCheckbox("MyDeFrag" , 330,76,97,17)
Global $Button3 = GUICtrlCreateButton("Defragmenter", 330, 200, 75, 25, $WS_GROUP)
;-------------------------------------------------------------------------------
;-----------------------------PARTIE REGISTRES----------------------------------
;-------------------------------------------------------------------------------
Global $Checkbox17 = GUICtrlCreateCheckbox("CCleaner R" , 450 , 56 , 97 ,17 )
Global $Checkbox18 = GUICtrlCreateCheckbox("PageDeFrag" , 450 , 76 , 97 , 17 )
Global $Checkbox19 = GUICtrlCreateCheckbox("onelick" , 450 , 96 , 97 , 17 )
Global $Checkbox20 = GUICtrlCreateCheckbox("ARC", 450 , 116 , 97 , 17 )
Global $Checkbox21 = GUICtrlCreateCheckbox("WRC" , 450 , 136 , 97 , 17 )
Global $Checkbox22 = GUICtrlCreateCheckbox("Optimizr" , 450 , 156 , 97 , 17 )
Global $Button4 = GUICtrlCreateButton("Registres", 450, 200, 75, 25, $WS_GROUP)
;-------------------------------------------------------------------------------
;-----------------------------PARTIE OPTIMISATION-------------------------------
;-------------------------------------------------------------------------------
Global $Checkbox23 = GUICtrlCreateCheckbox("SMART" , 590 , 56 , 97 , 17 )
Global $Checkbox24 = GUICtrlCreateCheckbox("myCFG" , 590 , 76 , 97 , 17 )
Global $Checkbox25 = GUICtrlCreateCheckbox("ZEB" , 590 , 96 , 97 , 17 )
Global $Checkbox26 = GUICtrlCreateCheckbox("WASO" , 590 , 116 , 97 , 17 )
Global $Button5 = GUICtrlCreateButton("Optimisation", 590, 200, 75, 25, $WS_GROUP)
;-------------------------------------------------------------------------------
;-----------------------------PARTIE OPTIMISATION-------------------------------
;-------------------------------------------------------------------------------
Global $Button6 = GUICtrlCreateButton("Nettoyage rapide" , 40 , 270 , 100 , 20)
;-------------------------------------------------------------------------------
;-----------------------------PRINCIPAL----------------------------------------
;-------------------------------------------------------------------------------
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
$quitter=MsgBox(4 + 64, "SoClean", "Quitter l'application?")
If ($quitter=6) Then
Exit
EndIf
;-------------------------------------------------------------------------------
;Nettoyage
;-------------------------------------------------------------------------------
;utilisation du cas dans lequel on appuie sur le bouton1
Case $Button1
;lecture de la valeur des checkbox
$getCheckbox1 = GUICtrlRead($Checkbox1)
$getCheckbox2 = GUICtrlRead($Checkbox2)
$getCheckbox3 = GUICtrlRead($Checkbox3)
$getCheckbox4 = GUICtrlRead($Checkbox4)
$getCheckbox5 = GUICtrlRead($Checkbox5)
$getCheckbox6 = GUICtrlRead($Checkbox6)
$getCheckbox7 = GUICtrlRead($Checkbox7)
;test, si checkbox coché
If _IsChecked($Checkbox1) then
; lancement de la mise à jour java-
Run(@ProgramFilesDir & "\Java\jre6\bin\jucheck.exe")
EndIf
If _IsChecked($Checkbox2) then
; éxecution de CCleaner
RunWait(".\CORE\EXE\CCP\CCleaner.exe")
EndIf
If _IsChecked($Checkbox3) then
; éxecution de Quick Clean
RunWait(".\CORE\EXE\QC\Quick Clean.exe")
EndIf
If _IsChecked($Checkbox4) then
; éxecution de KCleaner
RunWait(".\CORE\EXE\KCP\KCleaner.exe")
EndIf
If _IsChecked($Checkbox5) then
; éxecution de GUP
RunWait(".\CORE\EXE\GUP\GlaryUtilitiesPortable.exe")
EndIf
If _IsChecked($Checkbox6) then
; éxecution de Javara
RunWait(".\CORE\EXE\RA\JAVARA.exe")
EndIf
If _IsChecked($Checkbox7) then
; éxecution de WDC
RunWait(".\CORE\EXE\WDC\WiseDiskCleaner.exe")
EndIf
;-------------------------------------------------------------------------------
;Spywares
;-------------------------------------------------------------------------------
Case $Button2
$getCheckbox8=GUICtrlRead($Checkbox8)
$getCheckbox9=GUICtrlRead($Checkbox9)
$getCheckbox10=GUICtrlRead($Checkbox10)
$getCheckbox11=GUICtrlRead($Checkbox11)
$getChecked12=GUICtrlRead($Checkbox12)
$getCheckbox13=GUICtrlRead($Checkbox13)
$getCheckbox14=GUICtrlRead($Checkbox14)
If _IsChecked($Checkbox8) then
; lancement de Malware byte
RunWait(".\CORE\EXE\CONFICKER\ES\CONFICKER.exe")
EndIf
If _IsChecked($Checkbox9) then
If (@ProgramFilesDir & "\Malwarebytes' Anti-Malware\") Then
RunWait(@ProgramFilesDir & "\Malwarebytes' Anti-Malware\mbam.exe /runupdate")
RunWait(@ProgramFilesDir & "\Malwarebytes' Anti-Malware\mbam.exe /fullscanterminate")
Else
RunWait(".\CORE\EXE\MB\MB.exe /verysilent")
RunWait(@ProgramFilesDir & "\Malwarebytes' Anti-Malware\mbam.exe /runupdate")
RunWait(@ProgramFilesDir & "\Malwarebytes' Anti-Malware\mbam.exe /fullscanterminate")
EndIf
EndIf
If _IsChecked($Checkbox10) then
; lancement de NORMAN
RunWait(".\CORE\EXE\NORMAN\NORMAN.exe")
EndIf
If _IsChecked($Checkbox11) Then
;lancement de l'installation de spybot s&d
If (@ProgramFilesDir & "\Spybot - Search & Destroy\SDMain.exe") Then
;mise à jour
Runwait(@ProgramFilesDir & "\Spybot - Search & Destroy\SDUpdate.exe /autoupdate /autoimmunize /autoclose")
;recherche
RunWait(@ProgramFilesDir & "\Spybot - Search & Destroy\SpybotSD.exe /autocheck /autofix /autoclose /norestart")
Else
;installation
Runwait(".\CORE\EXE\SB\SPYBOT.exe /sp- /verysilent /norestart /suppressmsgboxes /tasks=""quicklaunchicon,launchsdhelper")
;mise à jour
Runwait(@ProgramFilesDir & "\Spybot - Search & Destroy\SDUpdate.exe /autoupdate /autoimmunize /autoclose")
;recherche
runWait(@ProgramFilesDir & "\Spybot - Search & Destroy\SpybotSD.exe /autocheck /autofix /autoclose /norestart")
EndIf
EndIf
If _IsChecked($Checkbox12) Then
;lancement de RAC
RunWait(".\CORE\EXE\RAC\RAC.exe /silent /norestart")
EndIf
If _IsChecked($Checkbox13) Then
;lancement de facke
RunWait(".\CORE\EXE\RFA\RFA.exe")
EndIf
If _IsChecked($Checkbox14) Then
;lancement de super anti spyware
RunWait(".\CORE\EXE\SAS\SAS.COM")
EndIf
;-------------------------------------------------------------------------------
;defragmentation
;-------------------------------------------------------------------------------
Case $Button3
$getCheckbox15=GUICtrlRead($Checkbox15)
$getCheckbox16=GUICtrlRead($Checkbox16)
If _IsChecked($Checkbox15) Then
;lancement de PageDFrag
RunWait(".\CORE\EXE\PAGEDEFRAG\PAGEDFRAG.exe -o")
EndIf
If _IsChecked($Checkbox16) Then
;lancement de MyDeFrag
RunWait(".\CORE\EXE\MYDEFRAG\MYDEFRAG.exe -r .\Scripts\DefragmentOnly.MyD -v C:")
RunWait(".\CORE\EXE\MYDEFRAG\MYDEFRAG.exe -r .\Scripts\SystemDiskMonthly.MyD -v C:")
EndIf
;-------------------------------------------------------------------------------
;Registres
;-------------------------------------------------------------------------------
Case $Button4
$getCheckbox17=GUICtrlRead($Checkbox17)
$getCheckbox18=GUICtrlRead($Checkbox18)
$getCheckbox19=GUICtrlRead($Checkbox19)
$getCheckbox20=GUICtrlRead($Checkbox20)
$getCheckbox21=GUICtrlRead($Checkbox21)
$getCheckbox22=GUICtrlRead($Checkbox22)
If _IsChecked($Checkbox17 ) Then
;lancement de CCleaner - Registres
RunWait(".\CORE\EXE\CCP\CCleaner.exe /REGISTRY")
EndIf
If _IsChecked($Checkbox18) Then
;lancement de pagedefrag
RunWait(".\CORE\EXE\PAGEDEFRAG\PAGEDFRAG.exe -o")
EndIf
If _IsChecked($Checkbox19) Then
;lancement de oneclik optimizer
RunWait(".\CORE\EXE\GUP\APP\oneclickoptimizer.exe")
EndIf
If _IsChecked($Checkbox20) Then
;lancement de ARc
RunWait(".\CORE\EXE\ARC\ARC.exe")
EndIf
If _IsChecked($Checkbox21) Then
;lancement de Wise registry cleaner
RunWait(".\CORE\EXE\WRC\WiseRegistryCleaner.exe")
EndIf
If _IsChecked($Checkbox22) Then
;lancement de l'optimisation de base de registres
RunWait(".\CORE\EXE\ERUNT\NTREGOPT.EXE silent")
EndIf
;-------------------------------------------------------------------------------
;Optimisation
;-------------------------------------------------------------------------------
Case $Button5
$getCheckbox23=GUICtrlRead($Checkbox23)
$getCheckbox24=GUICtrlRead($Checkbox24)
$getCheckbox25=GUICtrlRead($Checkbox25)
$getCheckbox26=GUICtrlRead($Checkbox26)
If _IsChecked($Checkbox23) Then
;lancement de SMART
RunWait(".\CORE\EXE\SMARTU\SMART\SMART.EXE")
EndIf
If _IsChecked($Checkbox24) Then
;lancement de maconfig
RunWait(".\CORE\EXE\MAC\maconfig.exe")
EndIf
If _IsChecked($Checkbox25) Then
;lancement de Zeb utilities
RunWait(".\CORE\EXE\ZEB\Zeb-Utility.exe")
EndIf
If _IsChecked($Checkbox26) Then
;lancement de WASO
RunWait(".\CORE\EXE\UN\WASO.EXE")
EndIf
;-------------------------------------------------------------------------------
;Nettoyage rapide
;-------------------------------------------------------------------------------
Case $Button6
;Cas d'utilisation dans lequel on va lancer un nettoyage par défaut
;TO DO !
$disque=InputBox("SoClean" , "Quel disque voulez vous examinez ?") ; à developper
;scripts .bat
;suppression des temp
;iconcache
MsgBox(0 , "SoClean" , "Execution de VDCSM.exe" )
RunWait(".\CORE\EXE\LSI\VDCSM.exe")
MsgBox(0 , "SoClean" , "Execution de CCleaner en mode auto" )
Runwait(".\CORE\EXE\CCP\CCleaner.exe /auto")
MsgBox(0 , "SoClean" , "Execution de Oneclick optimizer" )
RunWait(".\CORE\EXE\GUP\APP\oneclickoptimizer.exe /schedulestart")
MsgBox(0, "SoClean" , "Execution de Wise Disk Cleaner")
RunWait(".\CORE\EXE\WDC\WiseDiskCleaner.exe -a -p")
MsgBox(0,"SoClean" , "Execution de mydefrag")
RunWait(".\CORE\EXE\MYDEFRAG\MYDEFRAG.EXE -r .\Scripts\SystemDiskDaily.MyD -v "); %variable
EndSwitch
WEnd
;fonction de control d'etat de la chekbox
Func _IsChecked($control)
Return BitAnd(GUICtrlRead($control),1) = 1
EndFunc
Bon week-end à tous.



