IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

VBScript Discussion :

obtenir la cible d'un racourci


Sujet :

VBScript

  1. #21
    Débutant  
    Avatar de koKoTis
    Profil pro
    Inscrit en
    Août 2006
    Messages
    3 438
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Août 2006
    Messages : 3 438
    Points : 2 415
    Points
    2 415
    Par défaut
    ceci me renvoi une erreur à la ligne 18:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    set WshShell = WScript.CreateObject("WScript.Shell")
     
    DesktopPath = WSHShell.SpecialFolders("Desktop")
     
     
    Set oFSO = CreateObject("Scripting.FileSystemObject")
    stRep = DesktopPath
     
    If oFSO.FolderExists(stRep) Then
     
     For each oFl in  oFSO.GetFolder(stRep).Files
       if LCase(oFso.GetExtensionName(oFl)) = "lnk" then 
           vrChmRccrc = replace(oFl.Path,"\","\\")
            'msgbox vrChmRccrc
            strComputer = "." 
            Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2") 
            Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_ShortcutFile WHERE Name = '" & vrChmRccrc & "'",,48) 
    wscript.echo  colItems.count
            For Each objItem in colItems 
     
               If not oFSO.FileExists(objItem.Target) Then
                   Set fsoFile = ofso.getFile(oFl.Path)
                   fsoFile.delete
               End If
     
               Wscript.Echo "Cible: " & objItem.Target
            Next
       End If
     Next
    End If

  2. #22
    Expert éminent sénior


    Profil pro
    Inscrit en
    Juin 2003
    Messages
    14 008
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2003
    Messages : 14 008
    Points : 20 038
    Points
    20 038
    Par défaut
    Citation Envoyé par koKoTis Voir le message
    ceci me renvoi une erreur à la ligne 18:
    et il faut qu'on t'apprenne à compter jusqu'à 18 ...? pour que tu nous dise de qu'elle ligne il s'agit ..? et quel est le message ..?

  3. #23
    Débutant  
    Avatar de koKoTis
    Profil pro
    Inscrit en
    Août 2006
    Messages
    3 438
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Août 2006
    Messages : 3 438
    Points : 2 415
    Points
    2 415
    Par défaut
    désole, il s'agit de cette ligne:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    wscript.echo  colItems.count
    erreu non spécifié

  4. #24
    Expert confirmé
    Avatar de ced600
    Homme Profil pro
    Développeur .NET
    Inscrit en
    Août 2006
    Messages
    3 364
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 42
    Localisation : France

    Informations professionnelles :
    Activité : Développeur .NET

    Informations forums :
    Inscription : Août 2006
    Messages : 3 364
    Points : 4 061
    Points
    4 061
    Par défaut
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    Dim DesktopPath
    Dim strComputer
     
    strComputer = "." 
     
    Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\CIMV2")
    set WshShell = WScript.CreateObject("WScript.Shell")
    Set oFSO = CreateObject("Scripting.FileSystemObject") 
     
    DesktopPath = WSHShell.SpecialFolders("Desktop")
     
    If oFSO.FolderExists(DesktopPath) Then
     
     For each oFl in  oFSO.GetFolder(DesktopPath).Files
       if LCase(oFso.GetExtensionName(oFl)) = "lnk" then 
           vrChmRccrc = replace(oFl.Path,"\","\\")
            msgbox "SELECT * FROM Win32_ShortcutFile WHERE Name = '" & vrChmRccrc & "'"
            Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_ShortcutFile WHERE Name = '" & vrChmRccrc & "'",,48) 
            For Each objItem in colItems 
    		msgbox "entrée"
     
               If not oFSO.FileExists(objItem.Target) Then
                   Set fsoFile = ofso.getFile(oFl.Path)
                   fsoFile.delete
               End If
     
               msgbox "Cible: " & objItem.Target
            Next
       End If
     Next
    End If
    En fait ce code marche, mais il ne regarde que dans alluser et defaultuser.
    Je ne sais pas comment on fait pour qu'il regarde dans le répertoire de l'utilisateur courant.
    Pourquoi faire compliqué lorsque l'on peut faire encore plus compliqué.

  5. #25
    Débutant  
    Avatar de koKoTis
    Profil pro
    Inscrit en
    Août 2006
    Messages
    3 438
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Août 2006
    Messages : 3 438
    Points : 2 415
    Points
    2 415
    Par défaut
    non chez moi il fait bien l'utilisateur actif

  6. #26
    Débutant  
    Avatar de koKoTis
    Profil pro
    Inscrit en
    Août 2006
    Messages
    3 438
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Août 2006
    Messages : 3 438
    Points : 2 415
    Points
    2 415
    Par défaut
    même comme ca ca ne marche pas:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    Set objArgs = WScript.Arguments 
    For I = 0 to objArgs.Count - 1 
       vrRecupChmFch = objArgs(I) 
    Next
     
           vrChmRccrc = replace(vrRecupChmFch,"\","\\")
     
    strComputer = "." 
    Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2") 
    Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_ShortcutFile WHERE Name = '" & vrChmRccrc & "'",,48)
    For Each objItem in colItems 
       Wscript.Echo "Cible: " & objItem.Target
    Next
    il doit y avoir une erreur quelque par

  7. #27
    Expert confirmé
    Avatar de ced600
    Homme Profil pro
    Développeur .NET
    Inscrit en
    Août 2006
    Messages
    3 364
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 42
    Localisation : France

    Informations professionnelles :
    Activité : Développeur .NET

    Informations forums :
    Inscription : Août 2006
    Messages : 3 364
    Points : 4 061
    Points
    4 061
    Par défaut
    tu veux faire quoi avec cela ?
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    Set objArgs = WScript.Arguments 
    For I = 0 to objArgs.Count - 1 
       vrRecupChmFch = objArgs(I) 
    Next
    Pourquoi faire compliqué lorsque l'on peut faire encore plus compliqué.

  8. #28
    Débutant  
    Avatar de koKoTis
    Profil pro
    Inscrit en
    Août 2006
    Messages
    3 438
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Août 2006
    Messages : 3 438
    Points : 2 415
    Points
    2 415
    Par défaut
    récupérer le chemin du fichier glisser sur le vbs

  9. #29
    Expert confirmé
    Avatar de ced600
    Homme Profil pro
    Développeur .NET
    Inscrit en
    Août 2006
    Messages
    3 364
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 42
    Localisation : France

    Informations professionnelles :
    Activité : Développeur .NET

    Informations forums :
    Inscription : Août 2006
    Messages : 3 364
    Points : 4 061
    Points
    4 061
    Par défaut
    avec ce code si tu passes 3 arguments au vbs, il enregistrera le dernier dans vrRecupChmFch.
    Pourquoi faire compliqué lorsque l'on peut faire encore plus compliqué.

  10. #30
    Débutant  
    Avatar de koKoTis
    Profil pro
    Inscrit en
    Août 2006
    Messages
    3 438
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Août 2006
    Messages : 3 438
    Points : 2 415
    Points
    2 415
    Par défaut
    j'ai pensser à un truc, j'ai ajouter un utilisateur tout le monde sur le répertoire utilisateur par l'onglet sécurité, et maitenant le script fonctionne parfaitement, c'été une question de droit d'administration

    merci encore pour votre aide



    je poste le script finale:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    set WshShell = WScript.CreateObject("WScript.Shell")
    Set oFSO = CreateObject("Scripting.FileSystemObject")
     
    DesktopPath = WSHShell.SpecialFolders("Desktop")
     
     
    If oFSO.FolderExists(DesktopPath) Then
     
     For each oFl in  oFSO.GetFolder(DesktopPath).Files
       if LCase(oFso.GetExtensionName(oFl)) = "lnk" then 
           vrChmRccrc = replace(oFl.Path,"\","\\")
            strComputer = "." 
            Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2") 
            Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_ShortcutFile WHERE Name = '" & vrChmRccrc & "'",,48) 
            For Each objItem in colItems 
     
               If not oFSO.FileExists(objItem.Target) Then
                    Variable = MsgBox("Voulez vous supprimer le raccourci: " & oFl.Path, vbYesNo)
                    If Variable = vbYes Then 
                         Set fsoFile = ofso.getFile(oFl.Path)
                         fsoFile.delete
                    End If
               End If
     
            Next
       End If
     Next
    End If

+ Répondre à la discussion
Cette discussion est résolue.
Page 2 sur 2 PremièrePremière 12

Discussions similaires

  1. Comment obtenir le répertoire cible
    Par mikeGo20 dans le forum VBA Access
    Réponses: 2
    Dernier message: 03/08/2009, 16h37
  2. [VB.NET] Obtenir la cible d'un raccourci
    Par Runan dans le forum Windows Forms
    Réponses: 2
    Dernier message: 02/05/2007, 14h54
  3. obtenir 100 lignes autour d'une valeur cible
    Par PickEpique dans le forum Langage SQL
    Réponses: 7
    Dernier message: 19/03/2007, 20h33
  4. Comment obtenir la liste des paramètres d'une SP ?
    Par Le Gritche dans le forum MS SQL Server
    Réponses: 2
    Dernier message: 14/03/2003, 16h54
  5. Obtenir les taches en cours
    Par mlerat22 dans le forum MFC
    Réponses: 3
    Dernier message: 17/06/2002, 12h36

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo