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 :

Application en cours


Sujet :

VBScript

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre éclairé
    Homme Profil pro
    retraité
    Inscrit en
    Juillet 2011
    Messages
    386
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 80
    Localisation : France, Pas de Calais (Nord Pas de Calais)

    Informations professionnelles :
    Activité : retraité

    Informations forums :
    Inscription : Juillet 2011
    Messages : 386
    Par défaut Application en cours
    Bonjour
    Peut-on savoir si une application est en cours d'exécution?

  2. #2
    Expert confirmé
    Avatar de hackoofr
    Homme Profil pro
    Enseignant
    Inscrit en
    Juin 2009
    Messages
    3 844
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 50
    Localisation : Tunisie

    Informations professionnelles :
    Activité : Enseignant

    Informations forums :
    Inscription : Juin 2009
    Messages : 3 844
    Par défaut
    Citation Envoyé par papyxy Voir le message
    Bonjour
    Peut-on savoir si une application est en cours d'exécution?

    Oui, je crois, il suffit de connaître, le nom de son processus

  3. #3
    Expert confirmé
    Avatar de hackoofr
    Homme Profil pro
    Enseignant
    Inscrit en
    Juin 2009
    Messages
    3 844
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 50
    Localisation : Tunisie

    Informations professionnelles :
    Activité : Enseignant

    Informations forums :
    Inscription : Juin 2009
    Messages : 3 844
    Par défaut
    Voici un exemple :
    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
    32
    33
    34
    35
    Titre = " Processus "& qq("Wscript.exe") &" en cours d'exécution "
    Set fso = CreateObject("Scripting.FileSystemObject")
    Set sho = CreateObject( "Wscript.Shell" )
    NomFichierLog="Processus VBScript.txt"
    temp = sho.ExpandEnvironmentStrings("%temp%")
    PathNomFichierLog = temp & "\" & NomFichierLog
    Set OutPut = fso.CreateTextFile(temp & "\" & NomFichierLog,1)
    count=0 
    strComputer = "."
    Call FindAndKillScript()
    Call Explorer(PathNomFichierLog)
    '***************************************************************************************************
    Function Explorer(File)
        Set ws=CreateObject("wscript.shell")
        ws.run "Explorer "& File & "\",1,True
    end Function
    '***************************************************************************************************
    Sub FindAndKillScript()
        Set colItems = GetObject("winmgmts:").ExecQuery("Select * from Win32_Process " _
        & "Where Name like '%wscript.exe%' AND NOT commandline like '%" & wsh.scriptname & "%'",,48)
        For Each objItem in colItems
            MsgBox "Arrêter ce script : " & objItem.CommandLine,48,Titre
            count= count + 1
            'msgbox Mid(objItem.CommandLine,InStr(objItem.CommandLine,""" """) + 2),64,Titre
            OutPut.WriteLine Mid(objItem.CommandLine,InStr(objItem.CommandLine,""" """) + 2)
            objItem.Terminate(0)
        Next
    OutPut.WriteLine
    OutPut.WriteLine count & Titre & "ont été arrêtés"
    End Sub
    '***************************************************************************************************
    Function qq(strIn)
        qq = Chr(34) & strIn & Chr(34)
    End Function
    '***************************************************************************************************

  4. #4
    Membre éclairé
    Homme Profil pro
    retraité
    Inscrit en
    Juillet 2011
    Messages
    386
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 80
    Localisation : France, Pas de Calais (Nord Pas de Calais)

    Informations professionnelles :
    Activité : retraité

    Informations forums :
    Inscription : Juillet 2011
    Messages : 386
    Par défaut
    En supposant qu'il s'agit d'un "HTA" ou d'un "VBS", exécuté depuis une fenêtre Explorer.

  5. #5
    Expert confirmé
    Avatar de hackoofr
    Homme Profil pro
    Enseignant
    Inscrit en
    Juin 2009
    Messages
    3 844
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 50
    Localisation : Tunisie

    Informations professionnelles :
    Activité : Enseignant

    Informations forums :
    Inscription : Juin 2009
    Messages : 3 844
    Par défaut
    Citation Envoyé par papyxy Voir le message
    En supposant qu'il s'agit d'un "HTA" ou d'un "VBS", exécuté depuis une fenêtre Explorer.
    Testez ce script
    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
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    Titre = " Processus "& qq("Wscript.exe") &" en cours d'exécution "
    Set fso = CreateObject("Scripting.FileSystemObject")
    Set sho = CreateObject( "Wscript.Shell" )
    NomFichierLog="Processus VBScript.txt"
    temp = sho.ExpandEnvironmentStrings("%temp%")
    PathNomFichierLog = temp & "\" & NomFichierLog
    Set OutPut = fso.CreateTextFile(temp & "\" & NomFichierLog,1)
    count=0 
    strComputer = "."
    Call Find("wscript.exe")
    Call Find("mshta.exe")
    Call Find("cmd.exe")
    Call Find("Firefox.exe")
    'etc.....
    '........
    '........
    '........
    Call Explorer(PathNomFichierLog)
    '***************************************************************************************************
    Function Explorer(File)
        Set ws=CreateObject("wscript.shell")
        ws.run "Explorer "& File & "\",1,True
    end Function
    '***************************************************************************************************
    Sub Find(MyProcess)
        Set colItems = GetObject("winmgmts:").ExecQuery("Select * from Win32_Process " _
        & "Where Name like '%"& MyProcess &"%' AND NOT commandline like '%" & wsh.scriptname & "%'",,48)
        For Each objItem in colItems
            MsgBox "Arrêter ce script : " & objItem.CommandLine,48,Titre
            count= count + 1
            'msgbox Mid(objItem.CommandLine,InStr(objItem.CommandLine,""" """) + 2),64,Titre
            OutPut.WriteLine Mid(objItem.CommandLine,InStr(objItem.CommandLine,""" """) + 2)
            objItem.Terminate(0)
        Next
    'OutPut.WriteLine
    'OutPut.WriteLine count & Titre & "ont été arrêtés"
    End Sub
    '***************************************************************************************************
    Function qq(strIn)
        qq = Chr(34) & strIn & Chr(34)
    End Function
    '***************************************************************************************************

  6. #6
    Membre éclairé
    Homme Profil pro
    retraité
    Inscrit en
    Juillet 2011
    Messages
    386
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 80
    Localisation : France, Pas de Calais (Nord Pas de Calais)

    Informations professionnelles :
    Activité : retraité

    Informations forums :
    Inscription : Juillet 2011
    Messages : 386
    Par défaut
    C'est bon, je vous remercie.
    (un peu compliqué pour mon petit cerveau mais ça fonctionne)

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Lister les applications en cours
    Par The Lord of Nesquik dans le forum Windows
    Réponses: 5
    Dernier message: 27/07/2006, 16h07
  2. Redemarrer l'application en cours
    Par jagboys dans le forum MFC
    Réponses: 1
    Dernier message: 28/05/2006, 17h27
  3. avoir la liste des application en cours
    Par badjinmb dans le forum API, COM et SDKs
    Réponses: 1
    Dernier message: 21/04/2006, 15h28
  4. Lister les applications en cour...
    Par deetox dans le forum API, COM et SDKs
    Réponses: 4
    Dernier message: 13/10/2005, 19h50
  5. Icones des applications en cours d'utilisation.
    Par mickaelguilbert dans le forum MFC
    Réponses: 4
    Dernier message: 31/08/2005, 10h15

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