Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
799 views
in Technique[技术] by (71.8m points)

batch file - How can I set a title that starts with comma, semicolon or equal sign?

Obviously it is possible to set title that contains cmd's standard delimiters but through TITLE command looks impossible to set a title that starts with a delimiter.

It is possible to create a new instance of CMD with such title:

start "==" cmd.exe

but not possible for the same instance.

It is possible also with .NET and Console.Title property but when it's called from batch file the tile lasts as long as the compiled exe runs:

@if (@X)==(@Y) @end /* JScript comment
@echo off
setlocal

for /f "tokens=* delims=" %%v in ('dir /b /s /a:-d  /o:-n "%SystemRoot%Microsoft.NETFramework*jsc.exe"') do (
   set "jsc=%%v"
)

if not defined jsc (
        echo !!! Installation of .NET framework needed !!!
        pause
        exit /b 3
)

rem echo %jsc%
::if not exist "%~n0.exe" (
        del /q /f %~n0.exe
        call "%jsc%" /nologo /out:"%~n0.exe" "%~dpsfnx0"
::)

call %~n0.exe %*

endlocal & exit  /b %errorlevel%


*/

import System;

var arguments:String[] = Environment.GetCommandLineArgs();
//Console.WriteLine(Console.Title);
if (arguments.length>0){
         Console.Title=arguments[1];
}
//Console.WriteLine(Console.Title); 

(Probably is possible through code injection)

Is there a windows 'native' way?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I found another way:

title ^A,string

where ^A is produced by entering 0 1 while holding down the ALT-key ( <pressALT><0><1><releaseALT> ).

You can get it into a file with echo ^A>>batch.bat and then moving it to the correct position with notepad (it's not shown in notepad, like a whitespace; broader than a space, but not as broad as a TAB)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...