Share via

Help with Task Scheduler

LARA 0 Reputation points
2023-12-14T03:24:20.1866667+00:00

How can I use Task Scheduler to trigger an event, such as starting a specific program, only when another program is starting or has started? For instance, I have an application that runs at startup (a password manager) and a second app that needs that PW manager. Can someone provide some useful tips to help me solve this issue?

Windows for business | Windows Client for IT Pros | User experience | Other
0 comments No comments

2 answers

Sort by: Most helpful
  1. Anonymous
    2023-12-18T02:00:32.6766667+00:00

    Hello,

    You may create a bat file, below is the example, kindly change your variable in the bold text.

    Function of the script is to start second.exe until your first.exe is running.

    @echo off

    :CheckFirstRunning

    tasklist /FI "IMAGENAME eq first.exe" 2>NUL | find /I /N "first.exe">NUL

    if "%ERRORLEVEL%"=="0" (

    echo first.exe is running.

    start "" second.exe

    ) else (

    echo first.exe is not running. Waiting for it to start...

    timeout /t 5 /nobreak >nul

    goto CheckFirstRunning

    )

    Was this answer helpful?


  2. MotoX80 37,696 Reputation points
    2023-12-15T20:26:48.62+00:00

    You can have the task scheduler run a Powershell script that looks for a program and when it detects it, it can launch another program.

    Here is an example that looks for notepad to be launched.

    while ($true) {
        if ((Get-Process notepad -ea SilentlyContinue).count -gt 0) {
            "Got him."
            break
        }
        Start-Sleep -Seconds 5
    }
    Start-Process Your-Other-Program.exe 
    

    Was this answer helpful?

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.