► Afficher le texte
Code : Tout sélectionner
#cs ----------------------------------------------------------------------------
AutoIt Version: 3.2.12.1
Author: SurPriseS
Script Function:
Automatisation pour BorderMaker.
#ce ----------------------------------------------------------------------------
#cs ----------------------------------------------------------------------------
Fichier REG :
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\Directory\shell\Bordermaker]
@="BorderMaker"
"Install"="OK"
[HKEY_CLASSES_ROOT\Directory\shell\Bordermaker\command]
@="\"C:\\Documents and Settings\\SurPriseS\\Bureau\\bordermaker\\Autobm.exe\" \"%1\""
#ce ----------------------------------------------------------------------------
;-----------------------------------------------------------Includes :
#include <GUIConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
;-----------------------------------------------------------Variables :
;-----------------------------------------------------------GUI :
$Form1 = GUICreate("BorderMaker Automatiser", 350, 140)
cmd_ok() ; Affichage ou non du script selon si ajout dans la ligne de commande.
$install_button = GUICtrlCreateButton("Install BorderMaker",230,10,110)
$install_script_button = GUICtrlCreateButton("Install Script",230,40,110)
$deinstall_button = GUICtrlCreateButton("Deinstall BorderMaker",230,70,110)
$deinstall_script_button = GUICtrlCreateButton("Deinstall Script",230,100,110)
verrif_install() ; cache/affiche les bouton
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
case $install_script_button
install_reg()
case $deinstall_script_button
deinstall_reg()
case $install_button
install_BM()
case $deinstall_button
deinstall_BM()
EndSwitch
WEnd
;-----------------------------------------------------------Fonctions :
func cmd_ok() ; Verification de l'ajout d'une ligne de commande dans le lancement du script
If $CmdLine[0] = 1 Then
GUISetState(@SW_hide) ; Si il y a un ajout dans ligne de commande, le script s'execute en silence
$chemin = $CmdLine[1]
MsgBox(0,"",$chemin)
exit
Else
GUISetState(@SW_SHOW); Si il n'y a pas d'ajout dans la ligne de commande, le script s'affiche
Endif
EndFunc
Func verrif_install() ; cache/affiche les bouton
If FileExists("C:\Bordermaker\BorderMaker.exe") Then
GUICtrlSetState($install_button, $GUI_DISABLE)
GUICtrlSetState($deinstall_button, $GUI_ENABLE)
Else
GUICtrlSetState($install_button, $GUI_ENABLE)
GUICtrlSetState($deinstall_button, $GUI_DISABLE)
endif
if RegRead("HKEY_CLASSES_ROOT\Directory\shell\Bordermaker","Install") then
GUICtrlSetState($install_script_button, $GUI_DISABLE)
GUICtrlSetState($deinstall_script_button, $GUI_ENABLE)
Else
GUICtrlSetState($install_script_button, $GUI_ENABLE)
GUICtrlSetState($deinstall_script_button, $GUI_DISABLE)
EndIf
EndFunc
Func install_BM()
DirCreate("C:\bordermaker\")
FileInstall("C:\Documents and Settings\cyber\Bureau\BorderMaker Automatiser\bordermaker.exe","C:\bordermaker\bordermaker.exe")
FileCopy(@ScriptDir & "\Autobm.exe","C:\bordermaker\Autobm.exe")
verrif_install()
EndFunc
Func deinstall_BM()
FileDelete("C:\bordermaker\bordermaker.exe")
verrif_install()
EndFunc
func install_reg()
RegWrite("HKEY_CLASSES_ROOT\Directory\shell\Bordermaker","","REG_SZ","BorderMaker")
RegWrite("HKEY_CLASSES_ROOT\Directory\shell\Bordermaker","Install","REG_SZ","OK")
RegWrite("HKEY_CLASSES_ROOT\Directory\shell\Bordermaker\command","","REG_SZ",'"C:\bordermaker\Autobm.exe" "%1"')
verrif_install()
EndFunc
Func deinstall_reg()
RegDelete("HKEY_CLASSES_ROOT\Directory\shell\Bordermaker")
verrif_install()
EndFunc
Bon voilà, toute la base du script est terminé (il me semble en tout cas

), il reste LA grosse partie au niveau du parsing XML.
Fonction du script pour le moment :
- Installation/désinstallation de Bordermaker.exe dans C:\bordermaker et copie du script dans se dossier
- Installation/désinstallation dans la base de registre pour le menu contextuel
- Si lancement du script directement = Menu d'installation/désinstallation
- Si lancement du script via le menu contextuel = Affichage du nom du dossier via un msgbox
Voilou ! si vous voyez des erreurs/trucs a améliorer

Si certain veulent compiler le script, penser a modifier le chemin pour le fileinstall dans les fonctions
Tout les fichiers sont ici :
http://www.k1der.net/~surprise/fichiers ... tomatiser/
EDIT : Sa touche a la base de registre DONC FAITE ATTENTION ! Tester avec succès sur 2 machines sous Xp PRO SP3.