Jump to content

How do I prevent multiple instances of the script.


Recommended Posts

I would like to prevent multiple instances of the (compiled) script from running.

The first thing I tried was

<code>

If ProcessExists(@ScriptName) <> 0 Then Exit(0)

</code>

but that kills the current process too.

Maybe if I knew the current PID.

<code>

If ProcessExists(@ScriptName) <> @ScriptPID Then Exit(0)

</code>

But that will get the last created process, probably the current instance.

I either need to test each PID or change the current process name while I check.

any ideas?

Link to post
Share on other sites

It looks like this only works for scripts with windows that show up.

<{POST_SNAPBACK}>

If I told you that you have about 200 open windows presently on your desktop, you probably would not believe me. But they are there. A given process can have 20 or so hidden windows.

Autoit uses a hidden window for it's process. FAQ 14 refers to this hidden window.

:lmao:

Link to post
Share on other sites
  • 7 years later...
  • 8 years later...
  • Developers
1 hour ago, rowish said:

It's been ages... 

Correct ... so please don't resurrect them as they are now wrong

1 hour ago, rowish said:

Question 14 is no longer listed.

Wrong: It is now FAQ 10 as you can clearly see. 

Jos

Edited by Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to post
Share on other sites
  • Jos locked this topic
Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...