Jump to content

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


PlagueDoctor

Recommended Posts

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.

Link to comment
Share on other sites

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"));
Link to comment
Share on other sites

 

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.

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

 

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:

Link to comment
Share on other sites

[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
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

  • 3 weeks later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

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.

  • Recently Browsing   0 members

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