Getting quotes in title bar of started command

swiftie

Old git Member
Member
VIP
Local time
9:01 AM
Messages
149
Location
Hampshire, England
If you open a command prompt window, and execute the command:

start "Test" test.bat

... then the command window title of the started command will be: Test

Is there a syntax which would set the title of the started command window to: "Test"

I've been fiddling with this for about an hour today, and on/off ever since I encountered Windows, but I've never found a solution.
 

My Computer My Computer

Computer type
PC/Desktop
Computer Manufacturer/Model Number
Arbico/Quiet i7377
OS
Windows 7 Ultimate x64
CPU
3.40 gigahertz Intel Core i7-3770 Multi-core (4 total)
Motherboard
ASUSTeK COMPUTER INC. P8Z77-V LX Rev X.0x
Memory
16Gb
Graphics Card(s)
AMD Radeon HD 7700
Sound Card
AMD High Definition Audio Device
Monitor(s) Displays
Samsung 2443BW/Lenovo L2240pwD
Screen Resolution
1920x1200 1050x1680
Hard Drives
OCZ-VERTEX450 (256 GB)
ST31000524AS (1000.20 GB)
Drobo 5D 5-disk enclosure
Seagate USB 1Tb
ST1500DL 003-9VT16L 1500.30 GB
Case
Special noise-reducing case
Cooling
Quiet fans
Keyboard
Lenovo SK-8815 Multimedia keyboard
Mouse
Logitech MX
Internet Speed
~7mbps
Antivirus
Microsoft Security Essentials (and caution)
Browser
Chrome/Opera/Firefox/IE/Off-by-One
Other Info
Acoustic Energy AEGO-M Speakers - incredible sound, given their size.
Hi Swiftie,

Is there a reason for not using single quotes for the title instead?
Code:
start "''Test''" test.bat
The above results in a title analogous in appearance as to what you'd might expect from:
Code:
start ""Test"" test.bat

Which clearly lobs excess double quotes intentionally.
 

My Computer My Computer

Computer type
PC/Desktop
OS
Windows 10, Windows 8.1 Pro, Windows 7 Professional, OS X El Capitan
The reason that I'm not using single quotes in the title is that I want the title to show (as near as possible) the parameters passed to a program of mine. The program accepts a parameter string, and then uses "start" to run a batch program in the background. I'd like the batch/background window to show the parameters.
I tried using the "TITLE" command in the batch program, but that had no effect whatsoever. "TITLE" seems sensitive to how the window was opened; if it is by the "START" command, "TITLE" does nothing.
 

My Computer My Computer

Computer type
PC/Desktop
Computer Manufacturer/Model Number
Arbico/Quiet i7377
OS
Windows 7 Ultimate x64
CPU
3.40 gigahertz Intel Core i7-3770 Multi-core (4 total)
Motherboard
ASUSTeK COMPUTER INC. P8Z77-V LX Rev X.0x
Memory
16Gb
Graphics Card(s)
AMD Radeon HD 7700
Sound Card
AMD High Definition Audio Device
Monitor(s) Displays
Samsung 2443BW/Lenovo L2240pwD
Screen Resolution
1920x1200 1050x1680
Hard Drives
OCZ-VERTEX450 (256 GB)
ST31000524AS (1000.20 GB)
Drobo 5D 5-disk enclosure
Seagate USB 1Tb
ST1500DL 003-9VT16L 1500.30 GB
Case
Special noise-reducing case
Cooling
Quiet fans
Keyboard
Lenovo SK-8815 Multimedia keyboard
Mouse
Logitech MX
Internet Speed
~7mbps
Antivirus
Microsoft Security Essentials (and caution)
Browser
Chrome/Opera/Firefox/IE/Off-by-One
Other Info
Acoustic Energy AEGO-M Speakers - incredible sound, given their size.
A Title command in your batch program is the way to go with your intentions. The command should work anywhere, no matter where it is issued.

Are you trying to pass parameters to the batch program through the Start command? It could be a syntax error with your command or because of a renowned bug by the Start command when passing arguments with spaces.

Could you please post a preview of how you are passing parameters to the batch program. Also your Title command within the script.
 

My Computer My Computer

Computer type
PC/Desktop
OS
Windows 10, Windows 8.1 Pro, Windows 7 Professional, OS X El Capitan
I agree that the Title command in my batch program should work, but here reality and theory diverge... it simply does not work. I have no means of determining why this is so, but it irritates me, so I come back to this problem periodically.
It all comes down to this irritation. I'll forget about this soon, but probably fiddle with it through my remaining years...

The lack of effect of the Title command might be caused by the way the programs interact. The program that I run from the command prompt, and the batch program are the same file/program. Perhaps that's confusing the Title command?

My program is written in the REXX language, and in called watch.rex
When called from the command line, watch.rex simply uses a Start command to invoke itself again (in a separate window) then exits. This is because watch.rex (when invoked as a batch program) runs forever, until killed. I got fed up of having to launch another DOS prompt while watch.rex was running, so I modified it to start it's own, separate DOS prompt.

If you want the details, then here goes. The following is REXX code. The variable "efn" containes the fully qualified filename of the running program (Exec File Name).

Parms = arg(1) /* Get arguments from command line */
Started = 'Started' /* String to indicate the started thread */
If word(parms,1) ¬= Started then do /* Start another copy of this pgm */
'Start "Watch' changestr('"',Parms,'""')'" rexx.exe "'efn'"' Started Parms
...

Notes:
1. In REXX, you can use single or double quotes. They are 100% interchangeable. You use whatever ones make your code more readable.
2. the changestr() function replaces all double-quote characters with pairs of double-quote characters.

P.S. I traced the program when in batch mode, and found the cause... The title command DOES change the title, but them it instantly changes back. The reason for this is that REXX run a host command in a separate thread, and when that thread terminates, REXX restores the environment, INCLUDING THE TITLE. This is why I was trying to set the title with the Start command. That works, but I run into the quote display problems. I knew this 10 years ago, and it's taken me a week to recall it. Sorry.
I doubt there is any way to fix this issue. I'll learn to live with it. I'll put a comment to this effect into my program, ready for when I come this way in another 10 years time!
 

My Computer My Computer

Computer type
PC/Desktop
Computer Manufacturer/Model Number
Arbico/Quiet i7377
OS
Windows 7 Ultimate x64
CPU
3.40 gigahertz Intel Core i7-3770 Multi-core (4 total)
Motherboard
ASUSTeK COMPUTER INC. P8Z77-V LX Rev X.0x
Memory
16Gb
Graphics Card(s)
AMD Radeon HD 7700
Sound Card
AMD High Definition Audio Device
Monitor(s) Displays
Samsung 2443BW/Lenovo L2240pwD
Screen Resolution
1920x1200 1050x1680
Hard Drives
OCZ-VERTEX450 (256 GB)
ST31000524AS (1000.20 GB)
Drobo 5D 5-disk enclosure
Seagate USB 1Tb
ST1500DL 003-9VT16L 1500.30 GB
Case
Special noise-reducing case
Cooling
Quiet fans
Keyboard
Lenovo SK-8815 Multimedia keyboard
Mouse
Logitech MX
Internet Speed
~7mbps
Antivirus
Microsoft Security Essentials (and caution)
Browser
Chrome/Opera/Firefox/IE/Off-by-One
Other Info
Acoustic Energy AEGO-M Speakers - incredible sound, given their size.
I may have a workaround...

My program builds and runs a Start command, and that Start command sets the window title.
Windows (all versions I've ever seen) eliminate quote characters from the window title.

But... my program could convert the quote characters (destined for the title) with ones which look the same, but have different ASCII values. I could use curly quotes The only problem with this is that the curly quotes are handed, and I'd have to work out the right/left nature of every quote character in the title I was trying to set. Remember, the title I'm after is supplied from the command I type in, so it's almost a random string. I think I'll give up at this point. :-)
 

My Computer My Computer

Computer type
PC/Desktop
Computer Manufacturer/Model Number
Arbico/Quiet i7377
OS
Windows 7 Ultimate x64
CPU
3.40 gigahertz Intel Core i7-3770 Multi-core (4 total)
Motherboard
ASUSTeK COMPUTER INC. P8Z77-V LX Rev X.0x
Memory
16Gb
Graphics Card(s)
AMD Radeon HD 7700
Sound Card
AMD High Definition Audio Device
Monitor(s) Displays
Samsung 2443BW/Lenovo L2240pwD
Screen Resolution
1920x1200 1050x1680
Hard Drives
OCZ-VERTEX450 (256 GB)
ST31000524AS (1000.20 GB)
Drobo 5D 5-disk enclosure
Seagate USB 1Tb
ST1500DL 003-9VT16L 1500.30 GB
Case
Special noise-reducing case
Cooling
Quiet fans
Keyboard
Lenovo SK-8815 Multimedia keyboard
Mouse
Logitech MX
Internet Speed
~7mbps
Antivirus
Microsoft Security Essentials (and caution)
Browser
Chrome/Opera/Firefox/IE/Off-by-One
Other Info
Acoustic Energy AEGO-M Speakers - incredible sound, given their size.
I still don't see why using two single quotes won't satisfy. Single quotes are preserved through the start command. Having two single quotes jointly will look exactly like a double quote.

E.g. Consider the lines:
Code:
REM cmd.exe
test.bat "x" "y"
Code:
REM test.bat 
start "Parameters acquired were: ''%~1'' ''%~2''"

This will start a new instance of Cmd with its title appearing a little something like this:

1.jpg

 

Which is quite accurate enough IMO, especially as only human eyes will be the interpreters of the title. Just convert double quote characters to two single quote characters.
 

My Computer My Computer

Computer type
PC/Desktop
OS
Windows 10, Windows 8.1 Pro, Windows 7 Professional, OS X El Capitan
Which is quite accurate enough IMO, especially as only human eyes will be the interpreters of the title. Just convert double quote characters to two single quote characters.
Good plan. Thank you!

It will take me a moment or two to work out exactly how many single quotes I need in my program to get the effect of two single quotes in my command string. I think sets of four should do the trick!

Programming rules:
Inside a string delimited by double quotes, single quotes have no special significance.
Inside a string delimited by double quotes, double-quote characters have no special significance.
if you need/want to use the include in a string the same quote as is being used to delimit the string, you have to double up the enclosed quote characters, e.g. 'Swifty''s program' or "An ""interesting"" idea"
 

My Computer My Computer

Computer type
PC/Desktop
Computer Manufacturer/Model Number
Arbico/Quiet i7377
OS
Windows 7 Ultimate x64
CPU
3.40 gigahertz Intel Core i7-3770 Multi-core (4 total)
Motherboard
ASUSTeK COMPUTER INC. P8Z77-V LX Rev X.0x
Memory
16Gb
Graphics Card(s)
AMD Radeon HD 7700
Sound Card
AMD High Definition Audio Device
Monitor(s) Displays
Samsung 2443BW/Lenovo L2240pwD
Screen Resolution
1920x1200 1050x1680
Hard Drives
OCZ-VERTEX450 (256 GB)
ST31000524AS (1000.20 GB)
Drobo 5D 5-disk enclosure
Seagate USB 1Tb
ST1500DL 003-9VT16L 1500.30 GB
Case
Special noise-reducing case
Cooling
Quiet fans
Keyboard
Lenovo SK-8815 Multimedia keyboard
Mouse
Logitech MX
Internet Speed
~7mbps
Antivirus
Microsoft Security Essentials (and caution)
Browser
Chrome/Opera/Firefox/IE/Off-by-One
Other Info
Acoustic Energy AEGO-M Speakers - incredible sound, given their size.
Back
Top