Close - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Close

I want to write a batch program for my windows xp computer, that does the following:

1) It activates itself whenever a specified program is run.

2) It closes a program if the program is running.

Now if #1 is impossible, then it is not nessesary but I need to be able to do #2. for example, I want the program to close solitare if I am playing solitare.

[hr]
[purple][italic]I remain gentelmen you obedeiant servant[b]
-OG[/purple]
[/b][/purple][/italic][/red]
[red]-Margalo ;-)

Comments

  • AsmGuru62AsmGuru62 Posts: 6,519Member
    : I want to write a batch program for my windows xp computer, that does the following:
    :
    : 1) It activates itself whenever a specified program is run.
    :
    : 2) It closes a program if the program is running.
    :
    : Now if #1 is impossible, then it is not nessesary but I need to be able to do #2. for example, I want the program to close solitare if I am playing solitare.
    :
    : [hr]
    : [purple][italic]I remain gentelmen you obedeiant servant[b]
    : -OG[/purple]
    : [/b][/purple][/italic][/red]
    : [red]-Margalo ;-)
    :
    [blue]You can run a program with a timer and tell it to scan the running applications every 20 sec and then kill some if you detect them. Of course, the reaction will not be instant, but still...[/blue]

  • MargaloMargalo Posts: 75Member
    : : I want to write a batch program for my windows xp computer, that does the following:
    : :
    : : 1) It activates itself whenever a specified program is run.
    : :
    : : 2) It closes a program if the program is running.
    : :
    : : Now if #1 is impossible, then it is not nessesary but I need to be able to do #2. for example, I want the program to close solitare if I am playing solitare.
    : :
    : : [hr]
    : : [purple][italic]I remain gentelmen you obedeiant servant[b]
    : : -OG[/purple]
    : : [/b][/purple][/italic][/red]
    : : [red]-Margalo ;-)
    : :
    : [blue]You can run a program with a timer and tell it to scan the running applications every 20 sec and then kill some if you detect them. Of course, the reaction will not be instant, but still...[/blue]
    :
    :
    [red]That option does sound apealing, but I will not pretend to be a master of the batch arts... I never knew it was possible to scan running aplications, and do you use the "kill" command, to kill the programs? if you do would using "kill" delete the program, or just stop it from running? [/red]
    [hr]
    [purple][italic]I remain gentelmen you obedeiant servant[b]
    -OG[/purple]
    [/b][/purple][/italic][/red]
    [red]-Margalo ;-)

  • AsmGuru62AsmGuru62 Posts: 6,519Member
    : : : I want to write a batch program for my windows xp computer, that does the following:
    : : :
    : : : 1) It activates itself whenever a specified program is run.
    : : :
    : : : 2) It closes a program if the program is running.
    : : :
    : : : Now if #1 is impossible, then it is not nessesary but I need to be able to do #2. for example, I want the program to close solitare if I am playing solitare.
    : : :
    : : : [hr]
    : : : [purple][italic]I remain gentelmen you obedeiant servant[b]
    : : : -OG[/purple]
    : : : [/b][/purple][/italic][/red]
    : : : [red]-Margalo ;-)
    : : :
    : : [blue]You can run a program with a timer and tell it to scan the running applications every 20 sec and then kill some if you detect them. Of course, the reaction will not be instant, but still...[/blue]
    : :
    : :
    : [red]That option does sound apealing, but I will not pretend to be a master of the batch arts... I never knew it was possible to scan running aplications, and do you use the "kill" command, to kill the programs? if you do would using "kill" delete the program, or just stop it from running? [/red]
    : [hr]
    : [purple][italic]I remain gentelmen you obedeiant servant[b]
    : -OG[/purple]
    : [/b][/purple][/italic][/red]
    : [red]-Margalo ;-)
    :
    :
    [blue]If you need a tool yo do that - try to search the Web, maybe there are some... If you want to write it yourself - you need to use Win32 API:

    EnumWindows() - scans running processes (or some of it)
    TerminateProcess () - kills running program[/blue]
  • MargaloMargalo Posts: 75Member
    : : : : I want to write a batch program for my windows xp computer, that does the following:
    : : : :
    : : : : 1) It activates itself whenever a specified program is run.
    : : : :
    : : : : 2) It closes a program if the program is running.
    : : : :
    : : : : Now if #1 is impossible, then it is not nessesary but I need to be able to do #2. for example, I want the program to close solitare if I am playing solitare.
    : : : :
    : : : : [hr]
    : : : : [purple][italic]I remain gentelmen you obedeiant servant[b]
    : : : : -OG[/purple]
    : : : : [/b][/purple][/italic][/red]
    : : : : [red]-Margalo ;-)
    : : : :
    : : : [blue]You can run a program with a timer and tell it to scan the running applications every 20 sec and then kill some if you detect them. Of course, the reaction will not be instant, but still...[/blue]
    : : :
    : : :
    : : [red]That option does sound apealing, but I will not pretend to be a master of the batch arts... I never knew it was possible to scan running aplications, and do you use the "kill" command, to kill the programs? if you do would using "kill" delete the program, or just stop it from running? [/red]
    : : [hr]
    : : [purple][italic]I remain gentelmen you obedeiant servant[b]
    : : -OG[/purple]
    : : [/b][/purple][/italic][/red]
    : : [red]-Margalo ;-)
    : :
    : :
    : [blue]If you need a tool yo do that - try to search the Web, maybe there are some... If you want to write it yourself - you need to use Win32 API:
    :
    : EnumWindows() - scans running processes (or some of it)
    : TerminateProcess () - kills running program[/blue]
    :
    [/red][purple] I thank thee! this has proved to be very usfull, If anything goes wrong i'll ask. Thanks again! [/purple]

    [red] -Margalo ;-)
Sign In or Register to comment.