4

I made a bat file and during execution, it displays a title in the command window.

The title includes the bat filename, and it is displayed in full, including the .bat extension.

The code I'm using to do this is shown below (see the Title command on the 5th line).

The names I have used:

  • Filename: Facebook.bat
  • Title (line 5): Hacking %~nx1 Called Domain which outputs Hacking Facebook.bat Called Domain in the title-bar.

I want the title-bar to read Hacking Facebook Called Domain.

How do I do this?

My bat file:

@echo off
color 0d
call :sub *.bat
:sub
Title Hacking %~nx1 Called Domain
echo Test 1
timeout /t 2
echo Test 2
timeout /t 2
echo Completed
timeout /t 2
exit

enter image description here

  • It isn't clear what you are trying to accomplish. In Windows, the file extension is generally relied on to recognize the file type. A bat file won't work if you remove the extension. If you are talking about just hiding it, hiding it where? Is that the only extension you want hidden? Hidden just for this file? – fixer1234 Oct 12 '14 at 19:39
  • Hi, welcome to SuperUser. I've edited your question to make it more clear. If something seems wrong, feel free to edit it. – ᔕᖺᘎᕊ Oct 12 '14 at 19:41
  • no i don't want remove bat extension i want remove .bat from title – Ferit Uzun Oct 12 '14 at 19:43
  • Anybody Help Me ? – Ferit Uzun Oct 12 '14 at 19:47
  • 1
    I'm not understanding the title part. What it is the title of, where is it, and how is it used? – fixer1234 Oct 12 '14 at 19:51
10

The screenshot made the question much more clear.

I see you're using %~nx1 to show the filename in the title of the command prompt that shows up.

To use the filename without the extension, instead of using %~nx1, use %~n0.

ie:

@echo off
color 0d
call :sub *.bat
:sub
Title Hacking %~n0 Called Domain
echo Test 1
timeout /t 2
echo Test 2
timeout /t 2
echo Completed
timeout /t 2
exit

I got %~n0 from here.

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.