Sign in to follow this  
Followers 0
Doppio

Allow only one instance of a process to run

8 posts in this topic

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

Share this post


Link to post
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.


[center]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.[/center]

Share this post


Link to post
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.

 

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

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

[center]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.[/center]

Share this post


Link to post
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
Sign in to follow this  
Followers 0