Sign in to follow this  
Followers 0
dirty

How to self check if running

14 posts in this topic

#1 ·  Posted (edited)

Can you guys help me ? i cant figure out how to have script to check if its running, and if it is then just exit it but keep previous instance unaffected.

I tried

$proc = processexist ("test.exe")
if $proc > "" Then
Exit

This will exit its self as soon as i lauch it, but somehow i need to make it to maybe set status as "running" and then check for that status somehow ?

Just cant think of anything.

Thanks in advance.......

Edited by dirty

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

It sounds like you want _Singleton(), see helpfile.

Edit: Before I forget, you should change that avatar. You're basically saying you want to crush Jos and I don't think he would like that.

Edited by AdmiralAlkex

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Here's another option. It works with an open file.

Since it can't delete an open file, it will exit.

;#NoTrayIcon
; [-------------- Check Instance --------------]
If FileExists(@TempDir & "\temp.tmp") Then FileDelete(@TempDir & "\temp.tmp")
Sleep(500) ; <-- Might need to adjust value
If FileExists(@TempDir & "\temp.tmp") Then Exit
$OnlyOneInstanceAllowed = FileOpen(@TempDir & "\temp.tmp", 1)

It's an old trick -- but it works.

Of course, you would need to rename "temp.tmp" to something special

for your particular script.

Edited by ripdad

"Today's scientists have substituted mathematics for experiments, and they wander off through equation after equation, and eventually build a structure which has no relation to reality." ~ Nikola Tesla

Share this post


Link to post
Share on other sites

If singleton isn't doing what you want/need then Click Here this maybe what your after

Share this post


Link to post
Share on other sites

Why wouldn't:

If ProcessExists("text.exe") Then Exit

Work?

Share this post


Link to post
Share on other sites

Why not? If test.exe isn't running then the script would continue, otherwise it would close and let the previous one work.

Is test.exe an auto-it script or an exe to check?

Share this post


Link to post
Share on other sites

AdmiralAlkex, I should ban you for reporting this thread. I've lost 20 points of intelligence just reading it.

Anyway, as AdmiralAlkex has said, please change your avatar, dirty.

Share this post


Link to post
Share on other sites

AdmiralAlkex, I should ban you for reporting this thread. I've lost 20 points of intelligence just reading it.

Yeah maybe I should have sent it from the user profile. Sorry :D

Share this post


Link to post
Share on other sites

Why wouldn't:

If ProcessExists("text.exe") Then Exit

Work?

An exe can be renamed


"Today's scientists have substituted mathematics for experiments, and they wander off through equation after equation, and eventually build a structure which has no relation to reality." ~ Nikola Tesla

Share this post


Link to post
Share on other sites

So don't rename it?

Share this post


Link to post
Share on other sites

#12 ·  Posted (edited)

thanks guys.

If test.exe isn't running then the script would continue ?

No it wont run at all.... because once its executed it is considered as running process so EXIT.

I am also not after delighting or renaming files, so that wont work.

Thanks to admiral alkex for _Singleton(), thats all i needed to know :D

In the end

$filename = FileExists (@ScriptDir & "\GR4 loader.exe")
If $filename = 0 Then
    MsgBox(16,"Error","GR4 loader.exe was renamed. Please Rename back to GR4 loader.exe")
    Exit
    EndIf
if _Singleton("GR4 loader.exe",1) = 0 Then
    Msgbox(0,"Information.","Only one instance is allowed.")
    Exit
EndIf

Works just fine :huggles:

And come on guys my avatar is funny as hell.... but ill delete it if JOS wont like it. Hopefully ill get a warning before BAN for having avatars modified.

Plus his avatar does not say who it is, i just saw a picture and had a funny idea, crashing someone's name was not the plan.

Edited by dirty

Share this post


Link to post
Share on other sites

And come on guys my avatar is funny as hell.... but ill delete it if JOS wont like it. Hopefully ill get a warning before BAN for having avatars modified.

Plus his avatar does not say who it is, i just saw a picture and had a funny idea, crashing someone's name was not the plan.

You did get a warning. Also, I don't recall giving you a reason, I simply told you to change it. I don't necessarily agree with AdmiralAlkex's reason why you should change it but I do agree that you should change it. Now change your avatar before I do ban you since you have acknowledged you know it needs change.

Share this post


Link to post
Share on other sites

#14 ·  Posted (edited)

ure no fun.. :D

Edited by dirty

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