dirty Posted February 7, 2010 Share Posted February 7, 2010 (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 February 7, 2010 by dirty Link to comment Share on other sites More sharing options...
AdmiralAlkex Posted February 7, 2010 Share Posted February 7, 2010 (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 February 7, 2010 by AdmiralAlkex .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface Link to comment Share on other sites More sharing options...
ripdad Posted February 7, 2010 Share Posted February 7, 2010 (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 February 7, 2010 by ripdad "The mediocre teacher tells. The Good teacher explains. The superior teacher demonstrates. The great teacher inspires." -William Arthur Ward Link to comment Share on other sites More sharing options...
Thamiel Posted February 7, 2010 Share Posted February 7, 2010 If singleton isn't doing what you want/need then Click Here this maybe what your after Link to comment Share on other sites More sharing options...
darkjohn20 Posted February 8, 2010 Share Posted February 8, 2010 Why wouldn't: If ProcessExists("text.exe") Then Exit Work? Link to comment Share on other sites More sharing options...
AdmiralAlkex Posted February 8, 2010 Share Posted February 8, 2010 Why wouldn't:If ProcessExists("text.exe") Then ExitWork?Because then you wouldn't even be able to start 1 copy of your app .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface Link to comment Share on other sites More sharing options...
darkjohn20 Posted February 8, 2010 Share Posted February 8, 2010 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? Link to comment Share on other sites More sharing options...
Valik Posted February 8, 2010 Share Posted February 8, 2010 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. Link to comment Share on other sites More sharing options...
AdmiralAlkex Posted February 8, 2010 Share Posted February 8, 2010 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 .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface Link to comment Share on other sites More sharing options...
ripdad Posted February 8, 2010 Share Posted February 8, 2010 Why wouldn't:If ProcessExists("text.exe") Then ExitWork?An exe can be renamed "The mediocre teacher tells. The Good teacher explains. The superior teacher demonstrates. The great teacher inspires." -William Arthur Ward Link to comment Share on other sites More sharing options...
darkjohn20 Posted February 8, 2010 Share Posted February 8, 2010 So don't rename it? Link to comment Share on other sites More sharing options...
dirty Posted February 8, 2010 Author Share Posted February 8, 2010 (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 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 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 February 8, 2010 by dirty Link to comment Share on other sites More sharing options...
Valik Posted February 8, 2010 Share Posted February 8, 2010 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. Link to comment Share on other sites More sharing options...
dirty Posted February 8, 2010 Author Share Posted February 8, 2010 (edited) ure no fun.. Edited February 8, 2010 by dirty Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now