Batch file help

Soldato
Joined
17 Dec 2004
Posts
8,743
Is there anyway I can make a batch file, so for a example when I load notepad, a background app closes, then opens when notepad exits? or is that too complicated.
 
whats the use case?

here you go
first line kill the program you want to kill
second line opens notepad
once exited it will then open the third line

just save it as .bat & have fun
Code:
taskkill /IM notepad.exe
notepad.exe
"C:\Program Files\CPUID\CPU-Z\cpuz.exe"

nothing is to complicated, powershell is much more fun though :)


taskkill sends the WM_CLOSE message and it is then up to the application whether to properly close. You may also want to use the /T option to also signal child processes.

Only use the /F option if you want to force the termination of the process.

if you get errors then redirect the output like so:
taskkill /IM chrome.exe >nul
 
Last edited:
Thanks smogsy, I have a keyboard that doesnt show the caps lock, num lock ect status, so I use a program that shows it on the desktop (keyboard LEDs). But Alien Isolation keeps minimizing when the keyboard program is running...

So basically it would be good if I could get that program to close automatically when I run Alien Isolation, then start again when I close Alien Isolation
 
Sorted, thanks smogsy. I put the batch file in the game folder and put this in the file
Code:
taskkill /F /IM KeyboardLeds.exe > NUL
AI.exe
start /B KeyboardLeds.lnk

I put in "start /B C:\Program Files (x86)\Keyboard LEDs\KeyboardLeds.exe" but that didnt work, so I had to make a shortcut to it... Why didnt that work?
 
Would need to be..

start /B "C:\Program Files (x86)\Keyboard LEDs\KeyboardLeds.exe"

The spaces in the folder names break the command unless you put inverted commas around it :)


I use a similar thing for quickly killing certain games.

You know those games that crash, but don't give you desktop control so you can't see what's going on..

I use taskkill and list it mulitple times, once for each problematic game, then I create a shortcut to it called '1', now I dump that shortcut in C:\Windows\System32.

So to run the bat file, I press Winkey + R, type 1 (hit enter) and it kills the games.
 
the keyboardleds.exe still wont run. I get this now........

akwmbs.jpg
 
the keyboardleds.exe still wont run. I get this now........

akwmbs.jpg
try just "Path to keyboardexe" no start /B it should just launch without issue

or
taskkill /F /IM KeyboardLeds.exe > NUL
AI.exe
cd "folder path to Keyboard.exe"
KeyboardLeds.exe

it might be keyboardled not liking to start not from its folder. (bad programming on their part)
 
Seems like a lot of hassle. Get a new keyboard?:confused::p

I honestly don't think I even look at my LEDs. If I start typing and caps lock is on I just delete and turn it off? Same with scroll/num lock.

Good to be familiar with command line, though:)
 
Seems like a lot of hassle. Get a new keyboard?:confused::p

I honestly don't think I even look at my LEDs. If I start typing and caps lock is on I just delete and turn it off? Same with scroll/num lock.

Good to be familiar with command line, though:)

This is a new keyboard hehe, I had a wired keyboard and that did have LED's, but I have changed to the wireless version and it hasnt any LED's just a batt low LED..

I would buy a different keyboard, but this on goes amazingly well with the rest of my pc. This is the wired version of the keyboard but the wireless is identical.......

Old pics from last year...... Got a nice logitech mx master mouse in light grey too now.

15i3rf7.jpg


av2dls.jpg
 
Here's another pic with the mx master mouse and as you can see everything matches quite well, But the desk is more cluttered then before, that Im not too happy about, but I have to buy more stuff dont I arrghhh.

I would say to other people, do not get a light coloured mouse though, because you have to spend your time cleaning the dam thing as it goes a yellow colour from the oil in your skin and if you let it build up it stains the mouse. So I have to wipe it daily.

1onb49.jpg
 
Back
Top Bottom