Conditions batch "if"

Résolu
Bonjour, je souhaiterais faire un code pour dire si ce logiciel est fermer alors demarre ça. Merci d'avance pour vos réponses.

2 réponses

  1. Modérateur
    Bonjour,

    tasklist /FI "IMAGENAME eq myapp.exe" 2>NUL | find /I /N "myapp.exe">NUL
    if "%ERRORLEVEL%"=="0" echo Programm is running
    

    1. Bonjour, désolée pour ma réponse tardive, pourrais tu m'expliquer ta commande car je ne suis pas trop calée en programmation.
      1. Modérateur
        Lorsque tu ne comprends pas une commande ..... la première chose à faire (et c'est valable pour n'importe quel langage de programmation.....) c'est de regarder sur le net ce que ça dit...
        Par exemple :
        tasklist :https://www.google.fr/search?q=msdos+tasklist
        Tu tomberas alors sur des liens comme : https://www.computerhope.com/tasklist.htm

        et dedans :

        About tasklist
        This tool displays a list of currently running processes on either a local or remote machine.

        Tasklist syntax
        TASKLIST [/S system [/U username [/P [password]]]] [/M [module] | /SVC | /V] filter format /NH

        /S system Specifies the remote system to connect to.
        /U [domain\]user Specifies the user context under which the command should execute.
        /P [password] Specifies the password for the given user context. Prompts for input if omitted.
        /M [module] Lists all tasks currently using the given exe/dll name. If the module name is not specified all loaded modules are displayed.
        /SVC Displays services hosted in each process.
        /V Displays verbose task information.
        /FI filter Displays a set of tasks that match a given criteria specified by the filter.
        /FO format Specifies the output format. Valid values: "TABLE", "LIST", "CSV".
        /NH Specifies that the "Column Header" should not show in the output. Valid only for "TABLE" and "CSV" formats.