Set errorlevel from batch-file

前端 未结 2 1912
一个人的身影
一个人的身影 2021-01-22 01:50

I am working on this complicated (for me...) automation and one part is a batch script Started (not Called) from another one.

Now, it\'s all work-in-progress and I\'d l

相关标签:
2条回答
  • 2021-01-22 01:59

    cmd /c exit 1 will set the errorlevel to 1.

    0 讨论(0)
  • 2021-01-22 02:04

    If you want to have user input errorlevel you can use the choice command.

    @echo off
    choice /c 123456789
    echo %errorlevel%
    

    Depending on what you type on the order of the choice command the errorlevel will be set starting at 1.

    example:

    choice /c dghet
    

    pressing 'd' will make the errorlevel 1, and pressing h will make the errorlevel 3. Also as a perk you don't need to press enter after the input.

    0 讨论(0)
提交回复
热议问题