• Re: Tip: batch command line variables

    From Kerr-Mudd, John@admin@127.0.0.1 to alt.comp.os.windows-11,alt.msdos.batch on Sun Apr 26 09:03:48 2026
    From Newsgroup: alt.msdos.batch

    On Sat, 25 Apr 2026 22:21:11 -0700
    T <T@invalid.invalid> wrote:

    On 4/25/26 17:51, Java Jive wrote:
    On 2026-04-26 00:39, T wrote:
    On 4/25/26 16:08, Java Jive wrote:
    On 2026-04-25 13:08, T wrote:

    Assigning variable from call in Batch call drive
    me crazy.-a It is STUPID.

    And the relevance to your OP and my reply is?


    I was following up on the "for" command you mentioned.

    And since assigning a returned value to a variable is
    bizarre, I included how to do it.

    The relevance is that I was building on what you
    had added.-a I though you raised a good point.
    []
    I copied it down in my keeper and added the following:

    rem Switch to a known code page (CHCP command)
    CHCP 1252
    FOR /F "usebackq tokens=1-4" %%A IN (`CHCP`) DO (
    SET _CP=%%D
    )
    REM Restore original code page
    CHCP %_CP%

    Note: you really only need tokens=4 since you're only
    grabbing the last value

    and

    Without usebackq (default behavior)
    'command' raA runs a command
    "file name" raA treated as a file name (only works cleanly without spaces)

    With usebackq
    `command` raA runs a command
    'file name' raA treated as a file name (even with spaces)
    "literal string" raA treated as a plain string


    THANK YOU!!!



    Please note that amb is a much better fit for batch discussions; FU set
    --
    Bah, and indeed Humbug.
    --- Synchronet 3.21f-Linux NewsLink 1.2