Jump to content
UBot Underground

Force A Single Instance


Recommended Posts

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

Link to post
Share on other sites

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?

Link to post
Share on other sites

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 by juicehunter
Link to post
Share on other sites

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.

  • Like 1
Link to post
Share on other sites

Try this build https://mega.nz/#!Qw5jmCDS!luBzmi2ZyJSDMvZsAzPJnKfz9oju_l6iuWn4zydnpaM
Added 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 by juicehunter
  • Like 3
Link to post
Share on other sites

Try this build https://mega.nz/#!Qw5jmCDS!luBzmi2ZyJSDMvZsAzPJnKfz9oju_l6iuWn4zydnpaM

Added 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 {
        }
    }
}

Link to post
Share on other sites

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

  • Like 1
Link to post
Share on other sites

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 :)

Link to post
Share on other sites

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!")
        }
    }
}

Link to post
Share on other sites

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)
}
  • Like 3
Link to post
Share on other sites

 

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.

Link to post
Share on other sites

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/

Link to post
Share on other sites

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.

  • Like 1
Link to post
Share on other sites
  • 2 years later...

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 by gijosu
Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...