2
votes

I have a play application on a Windows 7 machine which I want to start via double click on a batch file.

This batch file starts a service. Calls the play application to run in production mode, waits for 5 seconds and open a browser with a specified url.

Therefore I used the following script:

call net start service1
CALL "D:\play-1.2.5\play.bat" start --%%%%prod -Dprecompiled=true
TIMEOUT /T 4
call "C:\Program Files (x86)\Mozilla Firefox\firefox.exe" localhost:9000
exit

Now when I start the batch file the window opens and all commands are executed. Sadly Play is still writing his output to cmd and the window is not disappearing. If I close the window manually play is stop executing.

If I run play with "play start" from cmd, play is starting in the background and everything is fine. Play still runs even if I close the window.

I want to have exactly this behaviour when I start the application with my batch file.

Thanks

3
In my Windows age I have struggled with this as well. But I ended up creating a scheduled tasks as my requirements changed.. In Mac I start play and then CTRL+C to close terminal.. - adis

3 Answers

0
votes

If you were using a linux-like environment, I' d recommend you to use 'nohup' command and a '&' sign in the end. However, as far as I know there is no direct equivalent of beautiful 'nohup' command on Windows, unfortunately. So, what I can think of is, you can create a tiny win api application that utilizes CreateProcess command and give it the required parameter to hide command line window as soon as the process is created. There are also other process creation functions such as WinExec that you can use to hide command line.

0
votes

I don't know what Play is so I can only take a guess :) but try using the batch without the call's as I don't think they are necessary, and you never know, might fix the issue.

0
votes

1) You see Play's output because ot redirect only system.out but write system.err to the same console.

2) I also have this problem and looking for a solution. As a workaround you could try to use some Java Wrapper and install your Play! application as a Windows Service.

3) Play! app could be started via Ant task. I haven't tried this yet.