TheNiers
TheNiers

Reputation: 237

Batch file won't kill process and close console window

Batch is a mystery to me. Here is the situation. I used a mouse macro program to create a .exe that automatically clicks on my screen. I want to automate this by adding it to my task scheduler. Here is the code that the program created:

@echo off
REM ************ Built by MiniMouseMacro.exe **********
cls
mode con lines=11 cols=115
title=Mini Mouse Macro - Turnssoft.com
color 0A
echo * Mini Mouse Macro *
echo   - "C:\Users\John Doe\Desktop\MiniMouseMacro.exe" /m "C:\Users\John Doe\Desktop\TestKlik.mmmacro"
echo   - Running C:\Users\John Doe\Desktop\TestKlik.mmmacro...
"C:\Users\John Doe\Desktop\MiniMouseMacro.exe" /m "C:\Users\John Doe\Desktop\TestKlik.mmmacro"

It opens the Macro program, loads the macro file (.mmmacro) and executes. This works. However, it keeps the console window open + it keeps the Macro program open (the mouse click opens a new program, might the console window lose focus or something?). I tried to fix this by adding this to the script:

echo   - killing process
taskkill /im "MiniMouseMacro.exe" /f
end

But nothing happens. How can I make this script work and also maybe make it look cleaner (I dont need all the text output).

Upvotes: 0

Views: 546

Answers (1)

Monacraft
Monacraft

Reputation: 6630

When you run the program, the cmd will wait for the program to finish before it continues. To change this use the start command when starting the mouse program.

cd "C:\Users\John Doe\Desktop\"
start "" "MiniMouseMacro.exe /m TestKlik.mmmacro"

Which will allow you to follow it with a taskkill

Upvotes: 1

Related Questions