New
#11
My batch file:
@echo off
taskkill /IM program1.exe /T /F
taskkill /IM program2.exe /T /F
pause
exit
My batch file:
@echo off
taskkill /IM program1.exe /T /F
taskkill /IM program2.exe /T /F
pause
exit
It seems to me that the Task scheduler element of this job is the one that is causing the difficulties so, if it still causing problems, screenshots of the Task scheduler Properties dialogs for the task would help us to help you.
On the subject of your batch file:-
- if you are still fault finding then leave out the @echo off so you can see the responses to your commands
- the exit command is not needed. It will exit after its last command anyway.
Denis
So I figured out how to do this using "pskill" form PSTools, but another issue cropped up. I add PSTools to the environment variables paths, and, when I click on the batch file manually, it works as intended using the command:
pskill -t "PROGRAM"
But... I am running this from a hotkey through another program. It doesn't work when I do that. Instead, I get an error indicating that "pskill is not a recognized local function", or something along those lines. Basically the same error you would get if pskill was not included environment paths.
I also notice that the working directory, when I run it through the hotkey, is different. Instead of being the directory where the batch file is saved, it is C:\Windows\System32. What gives? I have even tried changing the directory to C:\Windows\System32\PSTools, but the CD command doesn't even work when I run it through the hotkey. Is there a way to run pskill with the full directory path? i.e. something like...
C:\Windows\System32\PSTools\pskill.exe -t "PROGRAM"
Simply Install PSKill in your System32 directory. I always copy all the utilities I want handy right there, for years. And it served me well.
Right, it does work when I open cmd.exe or click on the Batch file and run it like that. It doesn't work when I use the hotkey program to run the batch file. I plan to go to the dev to ask why it would behave differently, but I would like to understand what is going on first.
Is there a way of running a batch file with limited capabilities? I'll post screen shots in a minute to show what I mean.
- - - Updated - - -
Here is what's going on. I have a batch file that runs another batch file. Batch file 1:
Batch file 2 (batch.bat):Code:start "" "C:\Location to bat file\batch.bat"
When I click on "batch file 1", I get this from "batch file 2":Code:pskill pause
When I program my hotkey program to run "batch file 1" on a key press, I get this from "batch file 2":
Obviously, the hotkey program is not running CMD.exe in the same way that Windows does. Not sure why, maybe the devs built in a paired down version when compiling the program? If it was run the same way, though, I should get the same results. Since I am running a batch file to run another batch file, can't I tell "batch file 1" to explicitly run "batch file 2" in the same way that Windows would do it. Something like:
Code:C:\Windows\System32\cmd.exe " start "" "C:\Location to bat file\batch.bat" "
Last edited by SSShadii; 26 Feb 2022 at 19:22.
Add to the start of your batch file 2, the line
so that it changes drive & folder to what you want.Code:CD /D "L:\Console games\hotkey"
Denis