1.

Solve : Monitoring a program??

Answer»

Hey, I was just wondering if it's possible to open a program from DOS, then wait until it's closed. I use Vista Sidebar, and when I play Starcraft it seems to change my resolution then mess up my apps. So, I was wondering if it's possible to kill the task, then open Starcraft (keeping the dos open) then once the program is done it reopens Vista Sidebar.

Example:

KILL SIDEBAR
OPEN STARCRAFT
WAIT STARCRAFT
ONCE CLOSED STARTCRAFT
OPEN SIDEBAR

I hope you UNDERSTAND, THANKS!in batch:
taskkill sidebar
start/wait starcraft.exe
do
tasklist|find "starcraft.exe"
sleep 5sec
loop until starcraft not found
start sidebar

i dont like loop part, not sure how much cpu resource it GOING to eat. if start/wait works, then it's BETTER solution.

in vbs:
terminate process sidebar
monitor for wmi deletionevent of starcraft process id.
create process sidebarCode: [Select]taskkill /F /IM sidebar.exe
start /wait C:\path\to\starcraft\starcraft.exe
start sidebar.exe
@Reno
there are no do loop in batch and if you use start /wait you dont have to check if it is running cos start /wait does itof course there is no do loop syntax in batch, it's just pseudocode.
i put the loop there in case start/wait is not working as it should be with starcraft.exe
the batch code:
:doloop
ping -n 5 localhost>nul
tasklist|find/i "starcraft.exe" && goto:doloop

is taskkilling a running process a good way?
how to send WM_CLOSE msg to an application?Quote from: devcom on April 05, 2009, 02:50:58 AM

Code: [Select]taskkill /F /IM sidebar.exe
start /wait C:\path\to\starcraft\starcraft.exe
start sidebar.exe
@Reno
there are no do loop in batch and if you use start /wait you dont have to check if it is running cos start /wait does it

Thank you very much, this worked perfectly! Thanks to you to Reno.np


Discussion

No Comment Found