none
'find' is not recognized as an internal or external command, operable program or batch file. RRS feed

  • Question

  • Hi, 

    I have a file check_count.bat with below contents: 

    echo off

    set file=udt_enroll_file.txt

    set /a cnt=0

    for /f %%a in ('type "%file%"^|find "" /v /c') do set /a cnt=%%a

    echo %file% has %cnt% lines

    echo %cnt%

    set file_cnt=%cnt%

    This is working as expected. 

    Now am trying to use this script in multiple scripts. So, say if I have a script test.bat with below contents

    echo here

    call check_count.bat

    when I run test.bat, am getting an error saying 

    'find' is not recognized as an internal or external command,
    operable program or batch file.

    This is the same behavior with other commands like 'net' / 'ping' etc....

    Please help me what am missing.

    Issue is observed in Windows Server 2012

    • Edited by Sun_Scripting_Win Thursday, May 11, 2017 3:49 AM
    • Moved by Bill_Stewart Friday, July 7, 2017 6:10 PM This is not break/fix Windows OS components forum
    Thursday, May 11, 2017 3:40 AM

All replies

  • Hi Sun,

    well ... the easiest fix would be to port the whole thing to PowerShell, which should have been done ~10 years ago. That would resolve all your process parameter / string issues and expand your scripting horizon by so many magnitudes, it's not even funny anymore.

    $lineCount = Get-Content udt_enroll_file.txt | Measure-Object | Select-Object -ExpandProperty Count

    Cheers,
    Fred


    There's no place like 127.0.0.1

    Thursday, May 11, 2017 6:10 AM