hiding the running program window - batch-file

I have .mp3 converted as .exe to
make it as self playing its done.
But a window is appearing while
music is playing.
I want to hide
that window while music is
playing [only using .bat file code]
So please help me for the .bat
file code

There is no way to hide a window in pure batch, your best alternative is to relaunch yourself (the .bat) with the START command and the /MIN switch, this would run it minimized and not hidden (You would use a special parameter and check %1 to see if you need to relaunch or not)

Related

cmd windows suddenly minimising to the taskbar

The past few days, whenever a cmd window opens (usually via a batch script or vbs file, but if I go to the Search box, type cmd and click on the cmd.exe result, that also does the same thing), the window opens on my desktop but immediately minimises to the taskbar. I want things back the way they were (no idea why the behaviour has changed), so that it remains up on my desktop, in its usual normal window, and I can read it. I am currently having to go down to the taskbar every time to bring it back up (which as I use quite a lot of scripting, is getting very frustrating).
If I launch the script from a shortcut, it will open normally; whereas if I click on the script file itself, it goes to the taskbar. Since many batch or vbs scripts I run are part of a larger one, they are all pointed to the .bat or .vbs script itself, not to a shortcut. For example, this extract from a vbs script, which launches the batch script from the bat file (not a shortcut to that file):
Dim objShell
Set objShell = WScript.CreateObject( "WScript.Shell" )
objShell.Run("""C:\Users\Martin\AppData\Roaming\Microsoft\Internet Explorer\Quick Launch\Batch Files\FS\PF3-XP_ini.bat""")
Set objShell = Nothing
Just to be clear, I have no instruction in the script itself for this to happen and scripts that I have used for years are now all being sent to the taskbar the second they open, instead of remaining in a readable window, as they always have in the past.
Can anyone please help me with this? Thanks.
Yes, true enough. In any case I tracked down the problem just this minute. I suddenly realised what must have happened. Sure enough, I have Windows Manager installed (which remembers window sizes on positions on multiple monitors) and the 'Freeze' option was off. So at some stage over the past few days I had obviously had a cmd window open and minimised it - WM had remembered this so that cmd windows always opened minimised thereafter. Don't know why that didn't occur to me sooner.
Luckily I had thought that this might happen and had made a backup of the WM profile. I just restored it and all is OK again.
Sorry for what in effect was a false alarm!

Play music file using Batch?

I am very confused as to how one would go about this. I want to use Batch to start an .mp3 file and while typing start file.mp3 plays the file, it opens the Media Player to do so. How would I play a music file in the background, but also have the ability to stop it whenever I please?
Windows Media Player with all its bells and whistles is not suitable for noninteractive listening. Use older version instead, which opens just a small window with a few necessary controls, plays the file and exits:
Mplay32.exe /Play /Close "file.mp3"
You may find more inspiration at
http://vitsoft.info/skimid3.htm#TalkingPlayer

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!

Remove the close option on a batch file with a command, is it possible?

I was just wondering if there is a code that can remove the "close" button on a batch file. (The minimize and expand buttons isn't important so it is ok if they will be disabled or will stay enabled) That is all. I can't seem to find any answer anywhere.
Thanks.
A batch file is nothing more that a script that another program must execute.
When you double-click a .bat file in Explorer, cmd.exe launches and "opens" the file, running the script. So your question is: can you remove the close button from cmd.exe? Good luck.
You don't want to be doing that. You should make your script NOT show a window to begin with.
If the window is shown, a user can always Ctrl + C to stop the script mid-stream.
There is a number of ways you can make the window hidden (also called "running a script silently"). See the following links:
Run a completely hidden batch file
Solved: HowTo run a batch file without it showing
Eric Helps
Or just google for "batch file silent" or "batch file hide console".
Just a side note: if you have seen this behavior before, chances are that it is not a batch file, but another programming language, and probably not using cmd.exe. C# can let you make a console program app which you can manipulate the title, but even still you cannot change the control buttons on the window. It is simply not within c# or a batch file's scope.

Start Play Application and Close Window

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.

Resources