Results 1 to 6 of 6
  1. #1
    hunterbdb is offline Member
    Join Date
    Oct 2008
    Posts
    48
    Rep Power
    0

    Default .BAT execution error

    I wrote a program that was pretty popular. It got stolen and redistributed illegally. Great, so now what I do: I'm using an executable program to help make it less steal-able. To do this, I need to be able to execute a .bat file from java. I have tried many different ways of doing it. None of them even made anything come up, except this method:

    My code:Runtime.getRuntime().exec("cmd /c start /MIN \"C:\\Documents and Settings\\blabla\\Desktop\\blabla\\Compile.bat\"") ;

    My Error:http://i207.photobucket.com/albums/b...db/aerror1.jpg

    This command only brings up this window^^. I want it to RUN (or start) the .bat file, not bring up this stupid CMD window. (yes, I know that a .bat is not an .exe) My workspace is PrivateScript. My .bat is Compile.bat



    So, who's up for the challenge? i can't say there's brownies in it for a reward, because I ate them. >.>



    .....But you'll have my sincere thanks if you help me!....whatever that's worth.
    Last edited by hunterbdb; 02-20-2009 at 11:49 PM.

  2. #2
    OrangeDog's Avatar
    OrangeDog is offline Senior Member
    Join Date
    Jan 2009
    Location
    Cambridge, UK
    Posts
    838
    Rep Power
    6

    Default

    The "start" command is just going to be opening windows and not running anything. Try again with "cmd /k \"path...

    However, there are probably better ways of making it less stealable than strange bat-hacking. Can you prove it was redistributed illegally? Have you tried prosecuting or suing. If you win it's unlikely anyone will do it to you again.

  3. #3
    toadaly is offline Senior Member
    Join Date
    Jan 2009
    Posts
    671
    Rep Power
    6

    Default

    It's pretty much impossible to make programs unstealable. Since it's already been stolen, what's the harm of sharing more with us so we can help you better? Exposing the code does not dishonor your copyright.

  4. #4
    hunterbdb is offline Member
    Join Date
    Oct 2008
    Posts
    48
    Rep Power
    0

    Default

    My new Code: Runtime.getRuntime().exec("cmd /k \"C:\\Documents and Settings\\blablabla\\Desktop\\blablabla\\Compile.b at\"");

    My new Error: Nothing comes up, nothing happens, I get no errors (yes, i try and catch and printstacktrace)

  5. #5
    hunterbdb is offline Member
    Join Date
    Oct 2008
    Posts
    48
    Rep Power
    0

    Default

    try{
    Runtime.getRuntime().exec("cmd /k CALL \"C:\\Documents and Settings\\blablabla\\Desktop\\blablabla\\Compile.b at\""); // Runs my code compilation Batch File Path
    }catch(RuntimeException e){
    e.printStackTrace();
    System.out.println(e);
    }


    This also does nothing, displays nothing. The methods which are called after it run.

  6. #6
    toadaly is offline Senior Member
    Join Date
    Jan 2009
    Posts
    671
    Rep Power
    6

    Default

    Do this (with appropriate try/catches):

    Java Code:
    Process p = Runtime.getRuntime().exec(...);
    p.waitFor();
    
    LineNumberReader r = new LineNumberReader(new InputStreamReader(p.getInputStream()));
    
    String line = r.readLine();
    while(line != null){
    System.out.println(line);
    line = r.readLine();
    }
    Then do the same thing for p.getErrorStream(). Perhaps this will tell you something. Also, verify that the command you are trying to execute will work in a DOS terminal window.

Similar Threads

  1. JAR execution
    By patoh in forum New To Java
    Replies: 2
    Last Post: 11-26-2008, 09:09 AM
  2. execution of threads
    By jyotigupta6 in forum Threads and Synchronization
    Replies: 5
    Last Post: 11-16-2008, 12:28 AM
  3. Package/Execution woes...
    By Hiro ZA in forum New To Java
    Replies: 2
    Last Post: 01-09-2008, 07:42 AM
  4. Execution methods Reflection
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 11-15-2007, 03:19 PM
  5. Execution cut
    By Eric in forum Advanced Java
    Replies: 1
    Last Post: 06-27-2007, 03:52 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •