none
"Simple" batch file woes.

    Question

  • I have various batch files that are called from login scripts....for example, rolling out cleanmgr sagesets and "inhibit IE8 installation" reghacks  ;)

    For each batch file, I use an IF EXIST checksum against a ver>appropriate_filename.TXT which results from the succesful first-run occasion.
    All of which works very nicely.

    I'd now like to place these checksum TXT files in a central area, so I can have visibility of which machines and profiles have, and which haven't, run a given batch file.
    As we have a busy TS environment, whose users also have access to hotdesk PCs, as well as their own laptops, I want %computername%-%username%-%date%.txt to be the target file I send ver> to.

    If I leave %computername%-%username%-%date%.txt just as it is, the file created is [NetBIOS name+ FirstName of the Username].txt, with the Surname and Date inserted into the TXT file.
    If I wrap quote marks around %username%, or anywhere else inside or outside the full filename, I get "the system could not find the path specified".

    Just so there's no risk of my missing out something important, a full copy of my batch file is shown below.

    I'm now in a "can't see the forest for all the trees" sitution, and request some assistance, please.

    One other thing...in the CMD window I see ">ver    1>filename.txt 
    What's the "    1" about?

    kind regards

    David

    ===Batch File Example begins ====
    pushd "\\holly\centralbatcheck\\" 
    cd cleanmgr_reg
    IF EXIST %computername%-%username%-%date%.txt GOTO end ELSE
    REGEDIT /S U:\IT\Patches\VOLCACHE.reg
    ver>%computername%-%username%-%date%.txt
    :end
    ===Batch File Example ends ====



    Monday, June 01, 2009 5:16 PM

Answers

  • ver>%computername%-%username%-%date%.txt or maybe ver>"%computername%-%username%-%date%.txt" work with system locales that don't have / or other forbidden charcters in the date format.
    I suspect that %date% contains slashes on your system and that doesn't work unless you process the date variable in some way to convert the slashes to underscore or something else that is allowed inside filenames.
    Try this, I think this should work:
    ver>"%computername%-%username%-%date:/=_%.txt"

    I don't have a good explanation about what the 1 in ver1>filename.txt is about but it's normal when piping output from commands. Never thought much about it.
    • Proposed as answer by perhof Tuesday, June 02, 2009 11:47 AM
    • Marked as answer by David _ Work Tuesday, June 02, 2009 11:52 AM
    Monday, June 01, 2009 10:45 PM

All replies

  • ver>%computername%-%username%-%date%.txt or maybe ver>"%computername%-%username%-%date%.txt" work with system locales that don't have / or other forbidden charcters in the date format.
    I suspect that %date% contains slashes on your system and that doesn't work unless you process the date variable in some way to convert the slashes to underscore or something else that is allowed inside filenames.
    Try this, I think this should work:
    ver>"%computername%-%username%-%date:/=_%.txt"

    I don't have a good explanation about what the 1 in ver1>filename.txt is about but it's normal when piping output from commands. Never thought much about it.
    • Proposed as answer by perhof Tuesday, June 02, 2009 11:47 AM
    • Marked as answer by David _ Work Tuesday, June 02, 2009 11:52 AM
    Monday, June 01, 2009 10:45 PM
  • I have a feeling you are seeing this because 1> is to redirect standard output.
    Tuesday, June 02, 2009 4:03 AM
  • ver>"%computername%-%username%-%date:/=_%.txt"
    Worked beautifully, very many thanks perhof.

    Tuesday, June 02, 2009 6:33 AM