Getting quotes in title bar of started command


  1. Posts : 149
    Windows 7 Ultimate x64
       #1

    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 Computer


  2. Posts : 721
    Windows 10, Windows 8.1 Pro, Windows 7 Professional, OS X El Capitan
       #2

    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


  3. Posts : 149
    Windows 7 Ultimate x64
    Thread Starter
       #3

    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


  4. Posts : 721
    Windows 10, Windows 8.1 Pro, Windows 7 Professional, OS X El Capitan
       #4

    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


  5. Posts : 149
    Windows 7 Ultimate x64
    Thread Starter
       #5

    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


  6. Posts : 149
    Windows 7 Ultimate x64
    Thread Starter
       #6

    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


  7. Posts : 721
    Windows 10, Windows 8.1 Pro, Windows 7 Professional, OS X El Capitan
       #7

    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 Computer


  8. Posts : 149
    Windows 7 Ultimate x64
    Thread Starter
       #8

    Pyprohly said:
    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


 

  Related Discussions
Our Sites
Site Links
About 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 20:41.
Find Us