Start Play Application and Close Window - batch-file

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

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.

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.

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.

Related

Cannot Open Mail using batch (.bat)

My Mail App for Windows 10 starts lagging like CRAZY with 4 second reaction times for each click. (yeah) When that happens I simply have to restart it to fix the issue. (No one has been able to understand why This happens when mail-app is idle)
I just thought I make a simple batch file who kills the app and restarts it each time I wanna open it so it always opens fresh. (Killing it takes just a second extra)
I managed to find that the name of the mail app process was HxOutlook.exe so I wrote this successful code
taskkill /IM HxOutlook.exe /F
But when trying to boot the process I cannot find out how. I tried the file directly but I get acces denied. Tried running is as my user which is admin, still same error. When trying to run as 'admin' it always says wrong password. However I don't want to have to enter password..
I found the HwOutlook folder and tried Using this code to call .exe:
runas /user:Administrator "C:\Program Files\WindowsApps\microsoft.windowscommunicationsapps_16005.11029.20108.0_x64__8wekyb3d8bbwe\HxOutlook.exe"
I also created a shortcut from the start menu and it says it executes microsoft.windowscommunicationsapps_8wekyb3. But trying to do that gets only error is not recognized as command or program
What can I add to the batch script to make it open the app again as if I click a shortcut like I can do in start, desktop and taskbar...
Just calling the shortcut from the desktop like Mail.lnk solved it for now.
taskkill /IM HxOutlook.exe /F
Mail.lnk

background process launched by TFS is killed when switching to next step

I have some trouble keeping alive a background process when launched by TFS.
Usually I use a batch that launch a java server (new window), as long as I keep this window open it works properly.
C:\Users\TFSService\mbs-iot-sdk\osgi\bin\vms\jdk\server.bat
In order to make my process automatic, I include this in TFS. In the step I call a batch that contains the following:
cd C:\Users\TFSService\mbs-iot-sdk\osgi\bin\vms\jdk // necessary to find the batch
start C:\Users\TFSService\mbs-iot-sdk\osgi\bin\vms\jdk\server.bat
In my task manager, I can see in background tasks that java is launched (no new window is opened), exactly as it behaves when launching directly the batch. But after a few seconds, when TFS switches to the next step, it stops.
Then the next step carries on but fails as it requires the server to be launched.
Is there a particular way of doing it in TFS ?
thank you
Alexandre
It's suggest to launch the .bat file from a relative path not directly use cd to hard code the path.
Also recommend you to use Run Batch File task not Run Command Line task to launch the .bat file.
According to your description, seems you are using a run command line task in your build pipeline. Then run the command under the working directory c:\Build_work\5\s, the command cd to C:\Users\TFSService\mbs-iot-sdk\osgi\bin\vms\jdk\ on the build agent, find the server.bat, run the server.bat.
First check if the .bat file is located at the path you are specifying on the build agent. Not sure if the bat file have to run under C:\Users\TFSService\mbs-iot-sdk\osgi\bin\vms\jdk\, guess you are also hard code the path in your server.bat file. Suggest you change all the path to relative path, you could use some built-in variable in TFS.
As for your workaround in comment, seems you want to chain builds in TFS. The official docs literally say "not yet" and have a uservoice in planed. However you could use some workaround, such as create or use other's customize extension (use rest api) to call another build. Detail ways please refer huserben's answer in this question: How to chain builds in TFS 2015?
Note sure you have to go deep into this area for your original issue. Just add some related info in case you are interested or need.
Well,
Just in case someone else goes through the same kind of issue, I found a workaround:
I wish to mix different command line steps, some of them launching Python scripts:
I have one step for launching the server that is required for my testing tool, one step for my testing tool and one Python step for differential testing
I realized that I could embed everything in a Python script.
It can handle server launching process in a separate window (with subprocess), launch my Python part and launch another process for my validation tool.
I have to test the whole chain but, at least, I solved my problem of launching a background process and detach it from TFS

How to run batch file via task scheduler to route print and keep the DOS window open/command line available to add text

in advance, thank you for any insight you may be able to offer. i know that there is a very similar post to my scenario and i have tried all variations of the answer but cannot get it to work for me as per the initial or edited instructions. in order to circumvent the uac nags, i am running windows 7 (64 bit) and trying to run a batch file to simply 'route print cmd /k' via task scheduler and desktop shortcut but i want the DOS window to remain open and allow me to continue typing into it. when i execute the actual file, it runs as desired, however when it runs via task scheduler, the dos window closes immediately. to no avail, i have tried multiple things such as changing the 'program/script' field from C:\location\batchfilename.bat to just cmd and inputting the various arguments including cmd /k or /k or /k C:\location\batchfilename.bat to the task's 'add arguments' field and/or the batch script itself. although i do not want pause as it would close the window after pressing any key, i have also tried it in the script itself and the arguments field but it too does not keep the dos window open when running as scheduled task. nothing seems to work - your help is greatly appreciated!

Run a application from batch file but hiding UI of that application

Is there any way to run the third party application, but user can't see the GUI of that application.
I am running the application and it is running, but what I want is to run it but user can't see the GUI of it.
Following code in batch file executes my application, here -w is a parameter which works as it is as one of the buttonPress event does form GUI-
#echo off
c:\xyz\abc.exe -w -pXXXXX
I want that if one runs the batch file, should not be able to see the GUI of that application so that pressButton event can't be created by the user.
May this http://www.robvanderwoude.com/ntstart.php will help. I mean /MIN key for the command

Running console app with parameters from NSIS installer

I am creating one installer for my project. Deployment of project needs some changes that are too complex with NSIS.
So for making it easy I have written one console app in C#. This app will do all the complex changes required with use of some parameters.
I just want to ask what is the way to call this console app with some parameters from my installer?
Is it possible by creating some batch file or what?
ExecWait '"$instdir\myapp.exe" /foo "hello world" /bar' is the basic method.
Use nsExec if you want to hide the console window and ExecDos or ExecCmd if you need more control...
You have several options to execute programs from NSIS, as documented here: http://nsis.sourceforge.net/Docs/Chapter4.html#4.9.1.2
Exec : Execute the specified program and continue immediately
ExecShell: Execute the specified program using ShellExecute
ExecWait: Execute the specified program and wait for the executed process to quit
the last solution is probably what you need.

Resources