How do i tell command prompt to open a batch file

Ethan Robinson 1 Reputation point
2022-08-05T13:01:36.103+00:00

Tasklist
Where If chrome.exe exist call cool
cool is my batch file but the thing is it doesn't find chome.exe and won't run the call?
Anyone know how to fix this?

Windows for business Windows Server User experience PowerShell
Microsoft Security Microsoft Sentinel
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. MotoX80 36,291 Reputation points
    2022-08-05T13:21:40.23+00:00

    Bat file version.

    tasklist | findstr -i chrome  
    if %errorlevel%==0 goto okay  
    @echo Chrome is not running.  
    goto end  
    :okay  
    @echo Chrome is running.  
    call c:\Myscripts\Cool.bat   
    :end  
    

    Powershell version.

    $chrome = Get-Process chrome -ErrorAction SilentlyContinue  
    if ($chrome) {  
        "Chrome is running."  
        cmd.exe /c c:\Myscripts\Cool.bat   
    } else {  
        "Chrome is not running."  
    }  
    

  2. Limitless Technology 39,916 Reputation points
    2022-08-08T10:24:56.71+00:00

    Hi there,

    Type cd followed by the full path to the folder with the .BAT file in the CMD terminal. Here’s an example:
    If the batch file is on your desktop, type cd \Users\YourLoginName\Desktop.
    If it’s in your downloads folder, type cd \Users\YourLoginName\Downloads.

    You can also use the following in your batch file:

    start cmd.exe /c "more-batch-commands-here"

    -----------------------------------------------------------------------------------------------------------------------------------

    --If the reply is helpful, please Upvote and Accept it as an answer–

    0 comments No comments

Your answer

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