Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set CMD title to a forward slash and a question mark (batch)

Tags:

batch-file

I am wondering if it is possible to change CMD's window title to /?

I've tried using ^/?, ^/^?, and "/?" but none of them seem to work.

Anyone got any suggestions?

Thanks

like image 305
ditheredtransparency Avatar asked Mar 02 '17 03:03

ditheredtransparency


1 Answers

It's possible with adding some invisible characters.
The idea is taken from @npocmaka SO: How can I set set a title that start with coma,semicolon or equal sign?
The problem of a title with a starting comma it can be solved also with a LF character, but in your case the LF doesn't help anywhere in the string.

@echo off

(set LF=^
%=empty=%
)

::Create a FS variable
call :hexprint "0x1C" FS

title /%FS%?
exit /b

:hexPrint  string  [rtnVar]
  for /f eol^=^%LF%%LF%^ delims^= %%A in (
    'forfiles /p "%~dp0." /m "%~nx0" /c "cmd /c echo(%~1"'
  ) do if "%~2" neq "" (set %~2=%%A) else echo(%%A
exit /b
like image 69
jeb Avatar answered Nov 09 '22 02:11

jeb