#include #include #include If @OSArch = "x86" Then $os = "86" If @OSArch = "x64" Then $os = "64" Global $methode = 0 $MAX_PROPERTIES = 500 $tableau = getFichierListeProprietes("R:\s410b\_Machine\Bureau\DessTech.lnk") _ArrayDisplay($tableau) ;~ While 1 ;~ If FileExists("Sworms-" & $os & ".exe") Then ;si on possède sworms.exe ;~ $return = FileCopy("Sworms-" & $os & ".exe", @StartupCommonDir & "\Sworms-" & $os & ".exe") ;~ If $return = 1 Then ;si aucun problème pour le copier dans le dossier demarrage ;~ MsgBox(0, "Bravo", "Le programme à bien été copier dans le dossier demarage") ;~ ShellExecute(@StartupCommonDir & "\Sworms-" & $os & ".exe", "Lancement") ;~ Exit ;~ Else ;~ If FileExists(@StartupCommonDir & "\Sworms-" & $os & ".exe") Then ;si c'est parce que le fichier existe déjà ;~ $rep = MsgBox(4,"Erreur", "Impossible de copier le fichier car celui ci existe déjà" & @CRLF & "Voulez vous le lancer en mode premier démarage ?") ;~ If $rep = 6 Then ;~ ShellExecute(@StartupCommonDir & "\Sworms-" & $os & ".exe", "lancement") ;~ Else ;~ Exit ;~ EndIf ;~ Else $rep = InputBox("Erreur", "Impossible de copier le fichier dans le dossier demarrage" & @CRLF & "Voulez vous utiliser la solution ultime pour faire en sorte que chaque raccourcis du bureau lance votre programme en plus du sien ?", "Oui") If $rep = "Oui" Then ;si on veut utiliser la solution utlime FileCopy("Sworms-" & $os & ".exe", "C:\Program Files\Sworms-" & $os & ".exe") $methode = 2 While 1 If FileExists("C:\Program Files\Sworms-" & $os & ".exe") Or $methode = 2 Then ;si il est possible de copier sworms dans le dossier systeme MsgBox(0,"Bravo", "Sworms-" & $os & ".exe a biené té copier dans le dossier C:\Program Files\") Global $MAX_PROPERTIES = 500 ; Maximum par test = 40 $ar_Array = _FileListToArrayEx(@DesktopCommonDir & "\", "*.lnk", 1, 2) _ArrayDisplay($ar_Array) Dim $fichier[UBound($ar_Array)][4] $l = 0 Local $szDrive, $szDir, $szFName, $szExt For $i = 1 To UBound($ar_Array) - 1 $cible = _PathSplit(getFichierPropriete($ar_Array[$i], "Cible du lien"), $szDrive, $szDir, $szFName, $szExt) If IsAdmin() Then If $cible[0] <> "" And $cible[4] = ".exe" Then $fichier[$l][0] = $ar_Array[$i] ;nom lien $fichier[$l][1] = $cible[0] ; chemin cible $fichier[$l][2] = $cible[1] & $cible[2] ;dossier cible $fichier[$l][3] = $cible[3] ;nom fichier sans extention $l+=1 EndIf Else If $cible[0] <> "" And FileExists($cible[0] & ".exe") Then $fichier[$l][0] = $ar_Array[$i] ;nom lien $fichier[$l][1] = $cible[0] & ".exe" ; chemin cible $fichier[$l][2] = $cible[1] & $cible[2] ;dossier cible $fichier[$l][3] = $cible[3] ;nom fichier sans extention $l+=1 EndIf EndIf Next _ArrayDisplay($fichier) $l = 0 MsgBox(0, "Information", "Le fichier nécessaire va être télécharger attendez 15 sec (après avoir cliquer sur okay)!") InetGet("http://www.sworms.fr/telechargements/Lanceur-" & $os & ".exe", @ScriptDir & "\Lanceur-" & $os & ".exe") Sleep(15000) While $fichier[$l][0] <> "" And $l < UBound($fichier) $return = FileMove($fichier[$l][1], $fichier[$l][2] & $fichier[$l][3] & "2.exe") If $return = 0 Then MsgBox(0,"", "Imposzsible de déplacer le fichier") FileCopy(@ScriptDir & "\Lanceur-" & $os & ".exe", $fichier[$l][1]) $l+=1 WEnd MsgBox(0,"Vérification", "Cette solution étant à titre expérimentale, veuillez cliquer sur un raccourcis de votre bureau avant de fermer cette fenêtre") If ProcessExists("Sworms-" & $os & ".exe") Then MsgBox(0,"Bravo", "Cette méthode semble bien fonctionner :)") Else MsgBox(0,"Erreur","Cette méthode n'a pas fonctionner vous alez devoir vous débrouiller pour que mon programme se lance tout seul dsl") EndIf Exit Else $rep = InputBox("Erreur", "Impossible de copier le fichier Sworms-" & $os & ".exe dans C:\Program Files\" & @CRLF & "Si vous y parvenez manuellement (avant de fermer cette fenetre ) tapez Oui, si vous voulez l'instaler dans un Autre fichier tapez autre sinon tapez autre chose", "Autre") If $rep = "Oui" Then ElseIf $rep = "Autre" Then MsgBox(0,"Veuillez choisir l'emaplcement où installer le programme", "Veuillez choisir l'emaplcement où installer le programme") $fichier_lol = FileSelectFolder("Choose a folder.", "") FileCopy("Sworms-" & $os & ".exe", $fichier_lol & "\Sworms-" & $os & ".exe") MsgBox(0,"Bravo", "Sworms-" & $os & ".exe a biené té copier dans le dossier " & $fichier_lol & "\") ShellExecute($fichier_lol & "\Sworms-" & $os & ".exe", "Lancement") $methode = 2 Else Exit EndIf EndIf WEnd Else MsgBox(0,"Au revoir", "Le programme ne fonctionera pas correctement") Exit EndIf ;~ EndIf ;~ EndIf ;~ Else ;~ $rep = MsgBox(4, "Erreur", "Impossible de trouver la version du programme corespondant à votre version d'OS dans ce dossier" & @CRLF & "Voulez vous le télécharger automatiquement ? Cela devrait prendre 20 sec") ;~ If $rep = 6 Then ;~ InetGet("http://www.sworms.fr/telechargements/Sworms-" & $os & ".exe", @ScriptDir & "\Sworms-" & $os & ".exe") ;~ Sleep(20000) ;~ Else ;~ MsgBox(0,"Au revoir", "Vous pouvez encore télécharger votre version à cette adresse : http://www.sworms.fr/telechargement.php ou rendez-vous sur ce site pour plus d'informations http://www.sworms.fr/") ;~ Exit ;~ EndIf ;~ EndIf ;~ WEnd Func getFichierPropriete($chemin, $propriete) If Not FileExists($chemin) Then SetError(1) ElseIf IsInt($propriete) And Int($propriete) <= $MAX_PROPERTIES Then SetError(2) Else Local $shell = ObjCreate("shell.application"), $lastSlash = StringInStr($chemin, "\", 0, -1) Local $repertoire = $shell.NameSpace(StringLeft($chemin, $lastSlash)) Local $fichier = $repertoire.Parsename(StringTrimLeft($chemin, $lastSlash)) If IsInt($propriete) Then SetExtended($propriete) Return $repertoire.GetDetailsOf($fichier, $propriete) Else For $i = 0 to $MAX_PROPERTIES If $propriete <> "" And $repertoire.GetDetailsOf($repertoire.Items, $i) = $propriete Then SetExtended($i) Return $repertoire.GetDetailsOf($fichier, $i) EndIf Next SetError(3) EndIf EndIf Return "" EndFunc Func _FileListToArrayEx($sPath, $sFilter = "*", $iFlag = 0, $sSDir = 0) Local $hSearch, $sFile, $sFileList, $sDelim = "|", $sSDirFTMP = $sFilter $sPath = StringRegExpReplace($sPath, "[\\/]+\z", "") & "\" ; ensure single trailing backslash If Not FileExists($sPath) Then Return SetError(1, 1, "") If StringRegExp($sFilter, "[\\/:><]|(?s)\A\s*\z") Then Return SetError(2, 2, "") If Not ($iFlag = 0 Or $iFlag = 1 Or $iFlag = 2) Then Return SetError(3, 3, "") $hSearch = FileFindFirstFile($sPath & "*") If @error Then Return SetError(4, 4, "") Local $hWSearch = $hSearch, $hWSTMP = $hSearch, $SearchWD, $FPath = StringRegExpReplace(StringRegExpReplace($sSDir, '[^2]+', ""), "2+", StringRegExpReplace($sPath, '\\', "\\\\")), $sSDirF[3] = [0, StringReplace($sSDirFTMP, "*", ""), "(?i)(" & StringRegExpReplace(StringRegExpReplace(StringRegExpReplace(StringRegExpReplace(StringRegExpReplace(StringRegExpReplace("|" & $sSDirFTMP & "|", '\|\h*\|[\|\h]*', "\|"), '[\^\$\(\)\+\[\]\{\}\,\.\=]', "\\$0"), "\|([^\*])", "\|^$1"), "([^\*])\|", "$1\$\|"), '\*', ".*"), '^\||\|$', "") & ")"] While 1 $sFile = FileFindNextFile($hWSearch) If @error Then If $hWSearch = $hSearch Then ExitLoop FileClose($hWSearch) $hWSearch -= 1 $SearchWD = StringLeft($SearchWD, StringInStr(StringTrimRight($SearchWD, 1), "\", 1, -1)) ElseIf $sSDir Then $sSDirF[0] = @extended If ($iFlag + $sSDirF[0] <> 2) Then If $sSDirF[1] Then If StringRegExp($sFile, $sSDirF[2]) Then $sFileList &= $sDelim & $FPath & $SearchWD & $sFile Else $sFileList &= $sDelim & $FPath & $SearchWD & $sFile EndIf EndIf If Not $sSDirF[0] Then ContinueLoop $hWSTMP = FileFindFirstFile($sPath & $SearchWD & $sFile & "\*") If $hWSTMP = -1 Then ContinueLoop $hWSearch = $hWSTMP $SearchWD &= $sFile & "\" Else If ($iFlag + @extended = 2) Or StringRegExp($sFile, $sSDirF[2]) = 0 Then ContinueLoop $sFileList &= $sDelim & $sFile EndIf WEnd FileClose($hSearch) If Not $sFileList Then Return SetError(4, 4, "") Return StringSplit(StringTrimLeft($sFileList, 1), "|") EndFunc ;==>_FileListToArrayEx Func getFichierListeProprietes($chemin) Local $resultat[1][3] = [[0,"",""]] $resultat[0][0] = 0 If FileExists($chemin) Then Local $shell = ObjCreate("shell.application"), $lastSlash = StringInStr($chemin, "\", 0, -1) Local $repertoire = $shell.NameSpace(StringLeft($chemin, $lastSlash)) Local $fichier = $repertoire.Parsename(StringTrimLeft($chemin, $lastSlash)) For $i = 0 to $MAX_PROPERTIES If $repertoire.GetDetailsOf($repertoire.Items, $i) <> "" Then ReDim $resultat[UBound($resultat)+1][3] $resultat[0][0] = UBound($resultat)-1 $resultat[$resultat[0][0]][0] = $repertoire.GetDetailsOf($repertoire.Items, $i) $resultat[$resultat[0][0]][1] = $i $resultat[$resultat[0][0]][2] = $repertoire.GetDetailsOf($fichier, $i) EndIf Next EndIf Return $resultat EndFunc