Set CMD header to slash and question mark (batch)

I am wondering if it is possible to change the name of the CMD window to /?

I tried using ^/? , ^/^? and "/?" but none of them work.

Anyone have any suggestions?

thanks

+6
source share
2 answers

This is possible with the addition of some invisible characters.
The idea is taken from @npocmaka SO: How to set a set of headings starting with a coma, semicolon or equal sign? The problem of a name with a starting comma can also be solved with the LF character, but in your case, 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 
+5
source
 @ECHO OFF if "%~1"=="_SO42546112_" ( shift ) else ( start "/?" cmd /D /K ""%~f0" "_SO42546112_"" exit ) 

To run the command line new CMD with the window title /? double click on the .bat script.


To run the .bat script header with /? , use the above concept, for example. in the following way:

 @ECHO OFF SETLOCAL EnableExtensions rem self wrapper - start if "%~1"=="_SO42546112_" ( shift ) else ( start "/?" cmd /D /C ""%~f0" "_SO42546112_" %*" exit /B rem โ†‘โ†‘ omit the `/B` switch to close calling `cmd` window ) rem self wrapper - end rem check whether the self wrapper works - start echo 1st "%~1" echo 2nd "%~2" echo 3rd "%~3" echo all %* pause rem check whether the self wrapper works - end rem original script continues here: 
+1
source

Source: https://habr.com/ru/post/1015389/


All Articles