Jump to content

Is it possible to run a bat file from inside a script?


Recommended Posts

Posted

Should be possible in Java, don't know if OSBot allows it tho.

http://bfy.tw/8hes

Hmm, i'm trying to write a muling script and my ideal way of doing it was starting a CLI bat file from within the script. I've tried a few different methods but they all so far don't work for one reason or another;

Process p =  Runtime.getRuntime().exec("cmd /c mule.bat", null, new File("C:\\Users\\Plague Doctor\\Desktop\\mule"));
Posted

 

Hmm, i'm trying to write a muling script and my ideal way of doing it was starting a CLI bat file from within the script. I've tried a few different methods but they all so far don't work for one reason or another;

Process p =  Runtime.getRuntime().exec("cmd /c mule.bat", null, new File("C:\\Users\\Plague Doctor\\Desktop\\mule"));

Check the logger, could be that OSBot blocks it due to security.

Posted

Put mule.bat file inside C:/users/%USERNAME%/OSBot/mule/mule.bat    

 

 String filePath = "C:/users/%USERNAME%/OSBot/mule/mule.bat";
        try {
            
            Process p = Runtime.getRuntime().exec(filePath);
            
        } catch (Exception e) {
            e.printStackTrace();
        }
  • Like 1
Posted (edited)

This may be an absolutely stupid question to some people, but i honestly don't know. Is it possible to run a bat file from inside an osbot script? If so, how? 

 

If its not possible, how would i go about starting another script when my player is in a certain area (without stopping the original script). 

 

Thanks.

 

If you want to start another script you can do:

List<String> command = new ArrayList<>();

Collections.addAll(command, "java", "-jar", "C:\\Path\\To\\OSBot.jar");
Collections.addAll(command, "-login", "username:password");

// add all the other parameters like above

ProcessBuilder processBuilder = new ProcessBuilder(command);
processBuilder.start();

You can check out the source of my OSBot Manager to see how I did it:

 

https://github.com/Explv/osbot_manager/blob/master/src/script_executor/ScriptExecutor.java

 

 

If you really want to store it in a .bat file then you can do the same as above but replacing the command with:

List<String> command = new ArrayList<>();

Collections.addAll(command, "cmd", "/c", "start");
command.add("C:\\Path\\To\\.bat");
Edited by Explv
  • Like 1
Posted

 

If you want to start another script you can do:

List<String> command = new ArrayList<>();

Collections.addAll(command, "java", "-jar", "C:\\Path\\To\\OSBot.jar");
Collections.addAll(command, "-login", "username:password");

// add all the other parameters like above

ProcessBuilder processBuilder = new ProcessBuilder(command);
processBuilder.start();

You can check out the source of my OSBot Manager to see how I did it:

 

https://github.com/Explv/osbot_manager/blob/master/src/script_executor/ScriptExecutor.java

 

 

If you really want to store it in a .bat file then you can do the same as above but replacing the command with:

List<String> command = new ArrayList<>();

Collections.addAll(command, "cmd", "/c", "start");
command.add("C:\\Path\\To\\.bat");

[ERROR][bot #1][11/12 01:53:29 AM]: Blocked permission: ("java.io.FilePermission" "<<ALL FILES>>" "execute")

 

Seems like the way im doing it isnt allowed :kappa:

Posted (edited)

[ERROR][bot #1][11/12 01:53:29 AM]: Blocked permission: ("java.io.FilePermission" "<<ALL FILES>>" "execute")

Seems like the way im doing it isnt allowed :kappa:

Indeed, I expected that OSBot would prevent you from executing files like that. Im not sure if there is a -allow CLI parameter for allowing such things, but I doubt it. You will need to figure out an alternative solution for muling :)

For example you could write a server that listens on a socket, when it receives a message from your script it runs the muling script

Edited by Explv
Posted

Indeed, I expected that OSBot would prevent you from executing files like that. Im not sure if there is a -allow CLI parameter for allowing such things, but I doubt it. You will need to figure out an alternative solution for muling smile.png

For example you could write a server that listens on a socket, when it receives a message from your script it runs the muling script

Thanks for the example, sounds like something very useful to learn. Looking into it now.

  • 3 weeks later...

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...