Synomenon Posted September 21, 2005 Share Posted September 21, 2005 Not sure if this should go in the programming forums, but can anyone please show me how to write a batch file that will launch a program and then close / exit another one at the same time, and then when the program that was launched is closed, re-launch / re-open the one that was closed in the beginning? This is for World of Warcraft and Logitech Setpoint. When World of Warcraft is launched, I want Logitech Setpoint to close and when I close World of Warcraft, I want Logitech Setpoint to re-launch. Thanks for any help. Link to comment Share on other sites More sharing options...
atomizer Posted September 21, 2005 Share Posted September 21, 2005 (edited) i'm not good at this and someone more knowledgeable may have a better solution, but this should work fine...TASKKILL /F /IM NameOfSetpointExecutable.exeCD "C:\Program Files\your game\NameOfGameExecutable.exe"START NameOfGameExecutable.exeECHO waiting for game to end...PAUSECD "C:\path to setpoint\NameOfSetpointExecutable.exe"START NameOfSetpointExecutable.exeEXITthis will leave the CMD shell running in the background. as soon as you're done with the game, hit any key and you're Logitech exe will start again.more info on "TASKKILL":TASKKILL [/s system [/u username [/P [password]]]] { [/FI filter] [/PID processid | /IM imagename] } [/F] [/T]Description: This command line tool can be used to end one or more processes. Processes can be killed by the process id or image name.Parameter List: /S system Specifies the remote system to connect to. /U [domain\]user Specifies the user context under which the command should execute. /P [password] Specifies the password for the given user context. Prompts for input if omitted. /F Specifies to forcefully terminate process(es). /FI filter Displays a set of tasks that match a given criteria specified by the filter. /PID process id Specifies the PID of the process that has to be terminated. /IM image name Specifies the image name of the process that has to be terminated. Wildcard '*' can be used to specify all image names. /T Tree kill: terminates the specified process and any child processes which were started by it. /? Displays this help/usage.Filters: Filter Name Valid Operators Valid Value(s) ----------- --------------- -------------- STATUS eq, ne RUNNING | NOT RESPONDING IMAGENAME eq, ne Image name PID eq, ne, gt, lt, ge, le PID value SESSION eq, ne, gt, lt, ge, le Session number. CPUTIME eq, ne, gt, lt, ge, le CPU time in the format of hh:mm:ss. hh - hours, mm - minutes, ss - seconds MEMUSAGE eq, ne, gt, lt, ge, le Memory usage in KB USERNAME eq, ne User name in [domain\]user format MODULES eq, ne DLL name SERVICES eq, ne Service name WINDOWTITLE eq, ne Window titleNOTE: Wildcard '*' for the /IM switch is accepted only with filters.NOTE: Termination of remote processes will always be done forcefully irrespective of whether /F option is specified or not.Examples: TASKKILL /S system /F /IM notepad.exe /T TASKKILL /PID 1230 /PID 1241 /PID 1253 /T TASKKILL /F /IM notepad.exe /IM mspaint.exe TASKKILL /F /FI "PID ge 1000" /FI "WINDOWTITLE ne untitle*" TASKKILL /F /FI "USERNAME eq NT AUTHORITY\SYSTEM" /IM notepad.exe TASKKILL /S system /U domain\username /FI "USERNAME ne NT*" /IM * TASKKILL /S system /U username /P password /FI "IMAGENAME eq note*" Edited September 21, 2005 by atomizer Link to comment Share on other sites More sharing options...
Synomenon Posted September 21, 2005 Author Share Posted September 21, 2005 Thanks atomizer. I made this one (just a test version) and it works perfectly for me:@echo off taskkill /f /im firefox.exe call "C:\Program Files\Windows Media Player\wmplayer.exe" start /d"C:\Program Files\Mozilla Firefox" firefox.exe goto :eofNow I just need to find out how to hide the DOS Window and taskbar button. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now