TheBigWeb 40 Posted October 24, 2015 Report Share Posted October 24, 2015 Hey guys, Anyone know if there is a way to only allow a single instance of a compiled bot? i.e. prevent multiple instances from being loaded? Thanks Quote Link to post Share on other sites
tessel 3 Posted October 24, 2015 Report Share Posted October 24, 2015 Yes, I'd like to know this as well. Quote Link to post Share on other sites
juicehunter 30 Posted October 25, 2015 Report Share Posted October 25, 2015 A mutex can do this, just need to add it to a plugin and it works out of the box. Quote Link to post Share on other sites
abbas786 78 Posted October 25, 2015 Report Share Posted October 25, 2015 Check All Processes for any instance of ur bot, if exists, stop ur current instance. Quote Link to post Share on other sites
juicehunter 30 Posted October 25, 2015 Report Share Posted October 25, 2015 Check All Processes for any instance of ur bot, if exists, stop ur current instance. A mutex will be much better and more reliable, i released it once in a free plugin called Open.Framework.DLL Quote Link to post Share on other sites
TheBigWeb 40 Posted October 25, 2015 Author Report Share Posted October 25, 2015 A mutex will be much better and more reliable, i released it once in a free plugin called Open.Framework.DLL Thanks for the reply. I have the plugin you mentioned but can't find a command that does this? Quote Link to post Share on other sites
kev123 132 Posted October 25, 2015 Report Share Posted October 25, 2015 can't remember but I think its called lock or system wide lock ages since I've used it. Quote Link to post Share on other sites
tessel 3 Posted October 25, 2015 Report Share Posted October 25, 2015 Any chance someone could link me to the Open.Framework.dll plugin? Searched and can't seem to find it on here. Quote Link to post Share on other sites
juicehunter 30 Posted October 26, 2015 Report Share Posted October 26, 2015 (edited) Any chance someone could link me to the Open.Framework.dll plugin? Searched and can't seem to find it on here.Here you go mate https://mega.nz/#!lgRlibLI!l1vLHSqjngeQQ48H-W3u8ssgnnAWNNtqY73qbE8CuxU Edited October 26, 2015 by juicehunter Quote Link to post Share on other sites
tessel 3 Posted October 26, 2015 Report Share Posted October 26, 2015 Thanks and um what's the decryption key? Quote Link to post Share on other sites
juicehunter 30 Posted October 26, 2015 Report Share Posted October 26, 2015 Thanks and um what's the decryption key? Juiceme, is the key, I know at this point not really protective. But we planned back there to make one big open source plugin out of it with all bell's and whistles. Basically like the include command seth introduced much later, but they wanted a way to protect the ubot code that was included. 1 Quote Link to post Share on other sites
tessel 3 Posted October 26, 2015 Report Share Posted October 26, 2015 Thank you! Quote Link to post Share on other sites
juicehunter 30 Posted October 26, 2015 Report Share Posted October 26, 2015 (edited) Try this build https://mega.nz/#!Qw5jmCDS!luBzmi2ZyJSDMvZsAzPJnKfz9oju_l6iuWn4zydnpaMAdded a function called "$is already running", it returns true if there is already another instance running. However it doesn't look at the process name, it checks the name you put in there. So make sure you use a different name in different apps. Hope you find it usefull. Edited October 26, 2015 by juicehunter 3 Quote Link to post Share on other sites
TheBigWeb 40 Posted October 27, 2015 Author Report Share Posted October 27, 2015 Try this build https://mega.nz/#!Qw5jmCDS!luBzmi2ZyJSDMvZsAzPJnKfz9oju_l6iuWn4zydnpaMAdded a function called "$is already running", it returns true if there is already another instance running. However it doesn't look at the process name, it checks the name you put in there. So make sure you use a different name in different apps. Hope you find it usefull. Many thanks for this although I can't seem to get it working? Here is the code below: - on load("Bot Loaded") { if($plugin function("Open.Framework.dll", "$is already running", "Test")) { then { alert("Already running") } else { } } } Quote Link to post Share on other sites
Code Docta (Nick C.) 638 Posted October 27, 2015 Report Share Posted October 27, 2015 Here is how to do without plugins in ubot 5 with Iron Python if($comparison($find regular expression($run python with result("import subprocesstlist = subprocess.check_output(\'tasklist\', shell=True)tlist"),"UBot Studio.exe"),"= Equals","UBot Studio.exe")) { then { alert("Yes!") } else { alert("No!") }} CD 1 Quote Link to post Share on other sites
Code Docta (Nick C.) 638 Posted October 27, 2015 Report Share Posted October 27, 2015 You can use Advanced shell plugin too from ubotdev.com use shell batch hidden func and just put TASKLIST in it and should get same results almost Quote Link to post Share on other sites
TheBigWeb 40 Posted October 27, 2015 Author Report Share Posted October 27, 2015 Here is how to do without plugins in ubot 5 with Iron Python if($comparison($find regular expression($run python with result("import subprocess tlist = subprocess.check_output(\'tasklist\', shell=True)tlist"),"UBot Studio.exe"),"= Equals","UBot Studio.exe")) { then { alert("Yes!") } else { alert("No!") }} CD You can use Advanced shell plugin too from ubotdev.com use shell batch hidden func and just put TASKLIST in it and should get same results almost Awesome both of you. Although it detects the 1st instance. I will have to perform a check that detects if there are two or more Quote Link to post Share on other sites
juicehunter 30 Posted October 27, 2015 Report Share Posted October 27, 2015 Only problem with using a sub process is that they can change the name of the exe and they bypassed it. Quote Link to post Share on other sites
TheBigWeb 40 Posted October 27, 2015 Author Report Share Posted October 27, 2015 OK here is some rough and ready code which works on load("Bot Loaded") { clear list(%test) add list to list(%test,$list from text($plugin function("Advanced Shell.dll", "$shell batch hidden", "cmd.exe /c tasklist"),$new line),"Don\'t Delete","Global") set(#count,0,"Global") loop($list total(%test)) { if($comparison($find regular expression($next list item(%test),"Test.exe"),"= Equals","Test.exe")) { then { increment(#count) } } } if($comparison(#count,"> Greater than",1)) { then { alert("Already Loaded!") } } } Quote Link to post Share on other sites
TheBigWeb 40 Posted October 27, 2015 Author Report Share Posted October 27, 2015 Thanks everyone for your input Quote Link to post Share on other sites
TheBigWeb 40 Posted October 27, 2015 Author Report Share Posted October 27, 2015 Here's a nice little function for you all: - define $isInstanceLoaded(#pProcessName) { comment("PURPOSE: Returns true if there is already and instance loaded ********") divider set(#_processCount,0,"Local") set(#_isLoaded,$false,"Local") add list to list(%_processes,$list from text($plugin function("Advanced Shell.dll", "$shell batch hidden", "cmd.exe /c tasklist"),$new line),"Don\'t Delete","Local") loop($list total(%_processes)) { if($comparison($find regular expression($next list item(%_processes),#pProcessName),"= Equals",#pProcessName)) { then { increment(#_processCount) } } } if($comparison(#_processCount,"> Greater than",1)) { then { set(#_isLoaded,$true,"Local") } } return(#_isLoaded) } 3 Quote Link to post Share on other sites
luis carlos 94 Posted October 27, 2015 Report Share Posted October 27, 2015 Here's a nice little function for you all: - define $isInstanceLoaded(#pProcessName) { comment("PURPOSE: Returns true if there is already and instance loaded ********") divider set(#_processCount,0,"Local") set(#_isLoaded,$false,"Local") add list to list(%_processes,$list from text($plugin function("Advanced Shell.dll", "$shell batch hidden", "cmd.exe /c tasklist"),$new line),"Don\'t Delete","Local") loop($list total(%_processes)) { if($comparison($find regular expression($next list item(%_processes),#pProcessName),"= Equals",#pProcessName)) { then { increment(#_processCount) } } } if($comparison(#_processCount,"> Greater than",1)) { then { set(#_isLoaded,$true,"Local") } } return(#_isLoaded) } Thanks for sharing! This thread and the one about the how to get the machine id, are really useful. Regads. Quote Link to post Share on other sites
Code Docta (Nick C.) 638 Posted October 27, 2015 Report Share Posted October 27, 2015 The fact that tasklist shows a process(your bot) should suffice. if shows in tasklist then don't run else run. but dude has a point they can change name of exe perhaps use $get current app from filemanagement plugin http://network.ubotstudio.com/forum/index.php/topic/13237-free-file-management-plugin-multiple-commands-and-functions/ Quote Link to post Share on other sites
TheBigWeb 40 Posted October 28, 2015 Author Report Share Posted October 28, 2015 The fact that tasklist shows a process(your bot) should suffice. if shows in tasklist then don't run else run. but dude has a point they can change name of exe perhaps use $get current app from filemanagement plugin http://network.ubotstudio.com/forum/index.php/topic/13237-free-file-management-plugin-multiple-commands-and-functions/ It won't work if you just check for the process because as soon as the bot is loaded it shows in the task manager so it detects itself and then won't run. You have to check for a second instance. 1 Quote Link to post Share on other sites
gijosu 9 Posted June 3, 2018 Report Share Posted June 3, 2018 (edited) Using this to force only one instance but if the software is renamed, this wont work I mean another instance will loaded, any workaround about this ? Edited June 3, 2018 by gijosu Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.