We help IT Professionals succeed at work.

How to prevent batch file name from displaying in the DOS window header when the batch file is running?

brgdotnet
brgdotnet asked
on
Medium Priority
139 Views
Last Modified: 2019-08-20
How do I control the information displayed in the dos window header?

If I run a batch file, it will display the name of the batch file in the header of the DOS window which it is running in. Also if I pass parameters to the batch file, it will display the name of the batch file followed by the parameters values passed. So how can I prevent batch file name and input parameter from being displayed in the header, when the batch file is running?
Comment
Watch Question

CERTIFIED EXPERT

Commented:
Hi brgdotnet

How do you start the batchfile? from another application or manually doubleclick on it?
(If from another application lor VB / VBA you can just HIDE the window.)


Regards
Thomas
Bill PrewTest your restores, not your backups...
CERTIFIED EXPERT
Expert of the Year 2019
Top Expert 2016

Commented:
Have you tried using the TITLE command to set whatever you want the title to be?


»bp
CERTIFIED EXPERT

Commented:
Bill is right.
Just add
TITLE This is the Title

Open in new window

at the beginning

Sample test.cmd
echo off
TITLE This is the title
echo "Only a placeholder"
echo %1
timeout 10

Open in new window


%1 would be the parameter to test it. Execute test.cmd "My little secret"
brgdotnetcontractor

Author

Commented:
Thanks all for the input. Setting the title will not fix this though. Take a look at the very simple batch file below. If I run this command from
the dos command line the name of the batch file is displayed along with the parameter which is being passed.  Setting the title will print the title in the header, but it will also display the name of the batch file it's input parameter, then followed by the title. Please see below for the batch file named "Cali.bat".


' Simple batch file that accepts one input parameter and also prompts for input :
@echo off
set arg1=%1
set /p id="Enter ID:"


From the dos command line I type the below passing in the input string of  "Drake":
The batch file runs but displays the batch file name, the input parameter and the TITLE in the header.
So how do I prevent the batch file name from being displayed? Or at least prevent the input parameter from being displayed?
>Cali.bat "Drake" TITLE ="Hello World"

Really what I want to do is to suppress the input parameter from being displayed? It is okay if the name of the batch file is displayed.
Bill PrewTest your restores, not your backups...
CERTIFIED EXPERT
Expert of the Year 2019
Top Expert 2016

Commented:
This should fix the problem, try this as your test BAT file.

@echo off
TITLE="Hello World"
set arg1=%1
set /p id="Enter ID:"

Open in new window


»bp
brgdotnetcontractor

Author

Commented:
Thanks Bill. The code I posted is a small example which I created myself. In real life my .cmd file is quite large. Unfortunately I am not allowed to change the command file and to add the TITLE inside of the .cmd file. Do you know, Is their anyway to suppress the input parameter in the header without setting the TITLE inside of the .cmd file?
 
I have tried this, but it is not working:

>Cali.bat "MyInputString" TITLE="Hello World"
NVITEnd-user support
CERTIFIED EXPERT

Commented:
Can you make and run another cmd file, using the contents of cali.bat? e.g.

echo TITLE="Hello World">runthis.bat
type Cali.bat >>runthis.bat
runthis.bat "MyInputString" 

Open in new window

Bill PrewTest your restores, not your backups...
CERTIFIED EXPERT
Expert of the Year 2019
Top Expert 2016

Commented:
I’m on mobile right now so can’t test, but can’t you launch the large CMD script via START and specify a title there?

~bp
brgdotnetcontractor

Author

Commented:
Nivit, that is pretty cool, but no, I am not allowed to pipe it to another batch file and run it like that.

Hey Bill, I tried it on the big .cmd file but it did not work. I even tried setting the title immediately before the execution of the batch file, and it still shows the input parameter.
Qlemo"Batchelor", Developer and EE Topic Advisor
CERTIFIED EXPERT
Top Expert 2015

Commented:
If you can't change the batch file or run a modified one, the only way I can see is to hide the window completely.
Did you try
@echo off
title Hello World
call Calibat "MyInputString"

Open in new window

CERTIFIED EXPERT

Commented:
Hi brgdotnet

Back to my inital question.

How is the batch started?
How starts the batch and how (doublecklick, taskmanager, etc).
Does the batch need to be visible for the user or the one who starts it?

regards
Thomas
Test your restores, not your backups...
CERTIFIED EXPERT
Expert of the Year 2019
Top Expert 2016
Commented:
This seems to work here:

START "" Cali.bat "Drake"

It runs the BAT file in a new window with a blank title.


»bp