Jump to content

Allow only one instance of a process to run


Doppio
 Share

Recommended Posts

How can this code be modified to allow only one instance of Iexplorer to Run.

While 1

If ProcessExists('IExplorer.exe') Then

Do

ProcessClose('IExplorer.exe')

Until Not ProcessExists('IExplorer.exe')

EndIf

Sleep(10)

WEnd

Thank you

Link to comment
Share on other sites

  • Moderators

Do you know the PID of the one you want to keep? If so gafrosts suggestion would be fine. If not, you'll never know which one you are killing.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

Do you know the PID of the one you want to keep? If so gafrosts suggestion would be fine. If not, you'll never know which one you are killing.

if not he's SOL anyways.

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Link to comment
Share on other sites

This is what I got so far

#NoTrayIcon

While 1

$list = ProcessList('IExplorer.exe')

$1 = "IExplorer.exe"

If $list [0][0] > 1 Then

ProcessClose('IExplorer.exe')

EndIf

Sleep(10)

WEnd

So far it works. Do you see anything that can be improved?

if not thank you for your input.

Link to comment
Share on other sites

  • Moderators

So you don't care which instance of IE is closed, just that there is always one?

@Mandar

Yes, don't define $1. It's not used.

#NoTrayIcon

While 1
$list = ProcessList('IExplorer.exe')
If $list [0][0] > 1 Then
ProcessClose('IExplorer.exe')
EndIf
Sleep(10)
WEndoÝ÷ Ûú®¢×ºÚ"µÍÚ[HBYPÝ[
ØÙÜÓÝ
    ÌÎNÒQ^Ü^IÌÎNÊJHHH    ÝÈH[ØÙÜÐÛÜÙJ   ÌÎNÒQ^Ü^IÌÎNÊBÛY
L
BÑ[
Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...