1.

Solve : Need Batch file to execute and close same program?

Answer»

Hello all.
I have rainmeter on my system, and game alot. I'm trying to figure out how to CREATE a single button on my desktop to open and close the program so as not to clutter my desktop with multiple icons for the same program. I currently have two separate files one for turning it on and the other for turning it off.

To turn on rainmeter I have the following batch

@echo off
cd "C:\Program Files\Rainmeter"
start Rainmeter.exe
EXIT

To turn off Rainmeter I have this batch

TASKKILL /f /im rainmeter.exe

Is there a way to COMBINE these into a single batch file so I have only one button that does both optionally?
This should "toggle" when you run it. If it's running it is terminated, if it's not running, it is launched.

Code: [Select]@echo off
cd "C:\Program Files\Rainmeter"
taskkill /f /im rainmeter.exe && echo "terminated Rainmeter" || rainmeter.exe
exit
Why not gracefully exit the program with the proper command LINE argument.

Code: [Select]"C:\Program Files\Rainmeter\Rainmeter.exe" !Quit



Discussion

No Comment Found