Autres tester si le fichier est dans un dossier system

Boostez vos compétences Excel avec notre communauté !

Rejoignez Excel Downloads, le rendez-vous des passionnés où l'entraide fait la force. Apprenez, échangez, progressez – et tout ça gratuitement ! 👉 Inscrivez-vous maintenant !

patricktoulon

XLDnaute Barbatruc
Bonjour à tous
avec les recentes mises du creatorRibbonX qui sera publiée entre le 15 et 31 mars 2026
mises à jours dues au fait que win 11 et plus drastiques en terme de securité
et dues aussi au fait que certains utilisateurs ne font pas les premières manip nécessaire a son bon fonctionnement (ils écoutent jamais )

je cherche une solution pour lancer un avertissement au cas ou le creatorRibbonX se trouve dans un dossier de windows
du genre downloads ou desktop ou document et autres

si dans un dossier system alors message et fermeture
comment faire ce test en un coup
 
Solution
re
excusez du dérangement j'ai repris un de mes vieux trucs avec shellapplication+namespaces
je balaye assez large dans les dossiers système

VB:
Sub test()
    MsgBox IsInSafeFolder(ThisWorkbook.Path)
End Sub

Function IsInSafeFolder(lpath As String) As Boolean
    'patricktoulon
    'cette fonction permet de dire si le path (lpath) est un dossier system ou pas
    Dim sheLLo As Object, syspath$, i%
    Set sheLLo = CreateObject("Shell.Application")
    IsInSafeFolder = True
     lpath = Trim(LCase(lpath))
     For i = 0 To 50
        On Error Resume Next
        syspath = sheLLo.Namespace(i).Self.Path
        If Err.Number <> 0 Then
            Err.Clear
        Else
            If lpath = LCase(Trim(syspath)) Then...
re
excusez du dérangement j'ai repris un de mes vieux trucs avec shellapplication+namespaces
je balaye assez large dans les dossiers système

VB:
Sub test()
    MsgBox IsInSafeFolder(ThisWorkbook.Path)
End Sub

Function IsInSafeFolder(lpath As String) As Boolean
    'patricktoulon
    'cette fonction permet de dire si le path (lpath) est un dossier system ou pas
    Dim sheLLo As Object, syspath$, i%
    Set sheLLo = CreateObject("Shell.Application")
    IsInSafeFolder = True
     lpath = Trim(LCase(lpath))
     For i = 0 To 50
        On Error Resume Next
        syspath = sheLLo.Namespace(i).Self.Path
        If Err.Number <> 0 Then
            Err.Clear
        Else
            If lpath = LCase(Trim(syspath)) Then
                IsInSafeFolder = False
                Set sheLLo = Nothing
                Exit Function
            End If
        End If
    Next
    On Error GoTo 0
    Set sheLLo = Nothing
End Function
 
Dernière édition:
je cherche une solution pour lancer un avertissement au cas ou le creatorRibbonX se trouve dans un dossier de windows
du genre downloads ou desktop ou document et autres

si dans un dossier system alors message et fermeture
comment faire ce test en un coup
Salut,
les dossiers Downloads desktop et documents sont plutôt des dossiers utilisateur non ?
Nullosse
 
re
bonjour
non non @nullosse c'est bien des dossiers system (les dossier sà l’intérieur c'est une autre histoire)
il font parti des specialfolder pour fso aussi

VB:
Sub truc()
    Set sheLLo = CreateObject("Shell.Application")
    For i = 0 To 50
        On Error Resume Next
        syspath = sheLLo.Namespace(i).Self.Path
        If Err.Number <> 0 Then
            Err.Clear
        Else
            Debug.Print "Index : " & i & " _ " & syspath '& " - " & ThisWorkbook.Path
            'If LCase(ThisWorkbook.Path) = LCase(Trim(syspath)) Then
                
            '    MsgBox "le fichier n'est pas dans un dossier safe"
                
            '    Set objShell = Nothing
                '
            'End If
        End If
    Next
End Sub

Index : 0 _ C:\Users\patricktoulon\Desktop
Index : 1 _ ::{871C5380-42A0-1069-A2EA-08002B30309D}
Index : 2 _ C:\Users\patricktoulon\AppData\Roaming\Microsoft\Windows\Start Menu\Programs
Index : 3 _ ::{26EE0668-A00A-44D7-9371-BEB064C98683}\0
Index : 4 _ ::{21EC2020-3AEA-1069-A2DD-08002B30309D}\::{2227A280-3AEA-1069-A2DE-08002B30309D}
Index : 5 _ C:\Users\patricktoulon\Documents
Index : 6 _ C:\Users\patricktoulon\Favorites
Index : 7 _ C:\Users\patricktoulon\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup
Index : 8 _ C:\Users\patricktoulon\AppData\Roaming\Microsoft\Windows\Recent
Index : 9 _ C:\Users\patricktoulon\AppData\Roaming\Microsoft\Windows\SendTo
Index : 10 _ ::{645FF040-5081-101B-9F08-00AA002F954E}
Index : 11 _ C:\Users\patricktoulon\AppData\Roaming\Microsoft\Windows\Start Menu
Index : 13 _ C:\Users\patricktoulon\Music
Index : 14 _ C:\Users\patricktoulon\Videos
Index : 16 _ C:\Users\patricktoulon\Desktop
Index : 17 _ ::{20D04FE0-3AEA-1069-A2D8-08002B30309D}
Index : 18 _ ::{F02C1A0D-BE21-4350-88B0-7367FC96EF3C}
Index : 19 _ C:\Users\patricktoulon\AppData\Roaming\Microsoft\Windows\Network Shortcuts
Index : 20 _ C:\Windows\Fonts
Index : 21 _ C:\Users\patricktoulon\AppData\Roaming\Microsoft\Windows\Templates
Index : 22 _ C:\ProgramData\Microsoft\Windows\Start Menu
Index : 23 _ C:\ProgramData\Microsoft\Windows\Start Menu\Programs
Index : 24 _ C:\ProgramData\Microsoft\Windows\Start Menu\Programs\StartUp
Index : 25 _ C:\Users\Public\Desktop
Index : 26 _ C:\Users\patricktoulon\AppData\Roaming
Index : 27 _ C:\Users\patricktoulon\AppData\Roaming\Microsoft\Windows\Printer Shortcuts
Index : 28 _ C:\Users\patricktoulon\AppData\Local
Index : 29 _ C:\Users\patricktoulon\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup
Index : 30 _ C:\ProgramData\Microsoft\Windows\Start Menu\Programs\StartUp
Index : 31 _ C:\Users\patricktoulon\Favorites
Index : 32 _ C:\Users\patricktoulon\AppData\Local\Microsoft\Windows\INetCache
Index : 33 _ C:\Users\patricktoulon\AppData\Local\Microsoft\Windows\INetCookies
Index : 34 _ C:\Users\patricktoulon\AppData\Local\Microsoft\Windows\History
Index : 35 _ C:\ProgramData
Index : 36 _ C:\Windows
Index : 37 _ C:\Windows\System32
Index : 38 _ C:\Program Files (x86)
Index : 39 _ C:\Users\patricktoulon\Pictures
Index : 40 _ C:\Users\patricktoulon
Index : 41 _ C:\Windows\SysWOW64
Index : 42 _ C:\Program Files (x86)
Index : 43 _ C:\Program Files (x86)\Common Files
Index : 44 _ C:\Program Files (x86)\Common Files
Index : 45 _ C:\ProgramData\Microsoft\Windows\Templates
Index : 46 _ C:\Users\Public\Documents
Index : 47 _ C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Administrative Tools
Index : 48 _ C:\Users\patricktoulon\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Administrative Tools
Index : 49 _ ::{21EC2020-3AEA-1069-A2DD-08002B30309D}\::{7007ACC7-3202-11D1-AAD2-00805FC1270E}
 
re
oui !! mais PAS !!! par robot
en l’occurrence ici le robot par exemple :msgbox createobject("shell.application").namespace(x).self.path
le robot c'est le shell.application
appelle de dossier par lui même ce n'est pas une manipulation manuelle de l'utilisateur
même si c'est l'utilisateur qui lance la macro
et ça win11 est encore plus sévère avec ça visiblement
tu a essayé la fonction dans un fichier verge enregistré sur le bureau par exemple
 
- Navigue sans publicité
- Accède à Cléa, notre assistante IA experte Excel... et pas que...
- Profite de fonctionnalités exclusives
Ton soutien permet à Excel Downloads de rester 100% gratuit et de continuer à rassembler les passionnés d'Excel.
Je deviens Supporter XLD

Discussions similaires

J
Réponses
3
Affichages
2 K
jujunexcelpas
J
Retour