Hobbyist

Error on "one stance"

5 posts in this topic

#1 ·  Posted (edited)

I have a newbie question.  I have made my executable and setup. Installed it on my pc. Included in my script is the check for more than one instance of the script running.  I have this error caught in a message box.

IF I have my windows file explorer open and do a single click on the script's program file folder and then go to the desk top icon for my script program and double click to open, I get the one instance error check message.

But I haven't started the script executable prior to double clicking the desk top Icon.

I hope this is clear. So I am asking is there something I don't know about making the one instance work.

This is what I am using.

$MyScript = " Dash Board"; name of the script
If WinExists($MyScript) Then
    MsgBox(16, "Notice", "Only One Instance Allowed ")
    Exit; It's already running
    AutoItWinSetTitle($MyScript)
EndIf

Thanks

 

Hobbyist

Edited by Hobbyist

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

1) you probably would want to look for processexists rather than winexists if that's the name of the executable

2) You really want singleton, so you should search "singleton"

Edited by iamtheky

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Share this post


Link to post
Share on other sites

Or check the help file for _Singleton.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Thanks to both of you.

I did go the Singleton route.  If I understood the ProcessExist help section, it continues to poll which seems to take resources.

 

Am I correct or misunderstanding?

 

Hobbyist

Share this post


Link to post
Share on other sites

Umm, that was not a good recommendation, just slightly more center than winexists, because:

$MyScript = " Dash Board"; name of the script
If WinExists($MyScript) Then

the whole 'name of the script' thing and then searching for a window of that name while asking about a check that would only allow a single instance of a process seemed crazy :)


,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

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