i'm trying to have my batch open another cmd based program, wait some time, then input some commands into the cmd-based program, but can't find any documentation on how to do it. this is the batch file as it is written so far:

start java -Xmx8192M -Xms8192M -jar minecraftforge-universal-1.6.2-
timeout /t 300
timeout /t 120
goto loop

basically, the program runs then after 300 secs its supposed to save then close, then wait 120 secs, then loop. but the batch as it is right now inputs the "save-all" and "stop" commands into itself rather than the running program. i have to use the "start" command to run it in a separate instance or else the batch never runs any of the following commands.

  • 1
    have you used sendkeys before ? Jan 4, 2014 at 1:17
  • @Knuckle-Dragger sendkeys in what? he is asking about batch. this superuser question asks about sendkeys in batch but the answers involve sendkeys in vbscript stackoverflow.com/questions/16454124/… So what do you mean when you say sendkeys. I remember in win9X there was a sendkeys 3rd party but i'ven ever seen it since. Have you run into something that works in windows 7?
    – barlop
    Jan 4, 2014 at 1:39
  • I can't answer your question however you should probably use arguments here for modded servers. Also, giving java more than 4GB ram is bad because it's bad at handeling it.
    – Jon
    Jan 4, 2014 at 1:39
  • @barlop, W7 has powershell, so it can be done from command line in batch file. see here superuser.com/questions/696467/… Jan 4, 2014 at 2:05
  • That is unless using a com-object is cheating. Jan 4, 2014 at 2:12

1 Answer 1


Perhaps you can pipe the commands into your running program. You want the left part of the pipe to wait before it echos the commands.

  timeout /t 300 /nobreak ^>nul^&echo save-all^&echo stop^&(call )
)|java -Xmx8192M -Xms8192M -jar minecraftforge-universal-1.6.2-
timeout /t 120 /nobreak
goto loop

The (call ) is a fast method to do a no-op. The extra command is needed to prevent a trailing space from being appended to the end of the stop command.

If that does not work, then you definitely can do what you want using AutoIT freeware.

  • @kelik - Did the pipe work? or did you use AutoIT?
    – dbenham
    Jan 4, 2014 at 14:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.