Windows 7 Forums

Welcome to Windows 7 Forums. Our forum is dedicated to helping you find support and solutions for any problems regarding your Windows 7 PC be it Dell, HP, Acer, Asus or a custom build. We also provide an extensive Windows 7 tutorial section that covers a wide range of tips and tricks.


Windows 7: Getting quotes in title bar of started command

09 Nov 2014   #1
swiftie

Windows 7 Ultimate x64
 
 
Getting quotes in title bar of started command

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 System SpecsSystem Spec
.
09 Nov 2014   #2
Pyprohly

Windows 10, Windows 8.1 Pro, Windows 7 Professional, OS X El Capitan
 
 

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 System SpecsSystem Spec
09 Nov 2014   #3
swiftie

Windows 7 Ultimate x64
 
 

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 System SpecsSystem Spec
.

09 Nov 2014   #4
Pyprohly

Windows 10, Windows 8.1 Pro, Windows 7 Professional, OS X El Capitan
 
 

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 System SpecsSystem Spec
10 Nov 2014   #5
swiftie

Windows 7 Ultimate x64
 
 

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 System SpecsSystem Spec
10 Nov 2014   #6
swiftie

Windows 7 Ultimate x64
 
 

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 System SpecsSystem Spec
10 Nov 2014   #7
Pyprohly

Windows 10, Windows 8.1 Pro, Windows 7 Professional, OS X El Capitan
 
 

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:

Getting quotes in title bar of started command-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 System SpecsSystem Spec
10 Nov 2014   #8
swiftie

Windows 7 Ultimate x64
 
 

Quote   Quote: Originally Posted by Pyprohly View Post
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 System SpecsSystem Spec
Reply

 Getting quotes in title bar of started command




Thread Tools Search this Thread
Search this Thread:

Advanced Search




Similar help and support threads
Thread Forum
{title} was not recorded due to a conflict with {title}
OK as the subject/title eludes to. I have Windows 7 Ultimate MCE and although it's recording OK, in the logs a few shows give me a recording conflict with themselves. So like "Bones was not recorded due to a conflict with Bones". In the history it records Bones and then also has an entry that...
Media Center
Quotes
Excuse my lack of know-how but can someone please explain how to quote someone who has replied to my last post. Many Thanks Steve
General Discussion
100 Quotes Every Geek Should Know
One thing that every geek can do is quote their favorite geek-culture media, whether it’s movies, books, television, theater or music. The GeekDads have tried to compile a list of such quotes for your enjoyment. 100 Quotes Every Geek Should Know | GeekDad | Wired.com “You maniacs! You blew...
Chillout Room
windows 7 and quotes
When I use a quote I have to pres other key (space for example) to display the ' is there any way to stop that ? I want to display the ' then I first press it. Hope you understood me :)
General Discussion


Our Sites

Site Links

About Us

Find Us

Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

Designer Media Ltd

All times are GMT -5. The time now is 11:29.

Twitter Facebook Google+



Windows 7 Forums

Seven Forums Android App Seven Forums IOS App