Batch--work to get the native IP address and then execute a recurring startup script

Source: Internet
Author: User

<pre name= "code" class= "CPP" ><span style= "font-size:18px;"   >goto:mainrem +++++++ Get native ip++++++++++++++++++++++++++++++++++++:get_local_iprem be careful not to copy some people's articles, if you write the function setlocal DoSomething endlocal This structure, then the return value in this code cannot be assigned, you get the return IP as "" @echo Offecho start to get native ip....................for/f "delims=:"%%i In (' ipconfig ^| findstr/n "local Connection" ') do (set/a op_line=%%igoto:for_break1): For_break1set ip_addr= "" set/a Op_num=%op_lin E%REM enable delay variable extension enable for Inside must use double! Do not use double% ah this is I found a lot of articles about deferred extension are didn't see?, I read their article simply can't, must use! Your own blood test results, you ask me why? Ghosts know this damned batch of syntax ... Setlocal Enabledelayedexpansionrem skip=%op_line% means skipping the preceding%op_line% line, starting with the%op_line%+1 line and processing delims= indicating that the file is being read by that character and dividing the line,  Line breaks are used here by default, or, for example, delims=+ indicates that each time a + sign is encountered, it is given as a line to the for internal code processing for/f "Skip=%op_line% delims="%%i in (1.tmp) does (REM digital operation with/a setset/a Op_num+=1rem here op_line can use% or! Because it does not have a change of logic because it does not delay the extension, then the variable has been given the entire block of code for the for before the for is considered to be a code, then the% variable will be replaced by the for before for the value before for, so that for the inside is like a constant general, Cannot change the for previously defined variable if!op_num! GTR%op_line% (set Tmp_i=%%iecho!tmp_i! | findstr "[0-9][0-9]*\.[ 0-9][0-9]*\. [0-9] [0-9]*\. [0-9] [0-9]*] Rem discovers the behavior address line if "!errorlevel!" = = "0" (: Loop_search_addr_posrem means <span style= "color: #ff0000;" > Intercept </span> take out the first character!tmp_i:~0,3! means <span style= "Background-color:rgb (255, 0, 0);" > Receive </span> take the first three characters set Tmp_i=!tmp_i:~1!echo!tmp_i! | Findstr "^[0-9][0-9]*\. [0-9] [0-9]*\. [0-9] [0-9]*\. [0-9]*[0-9] ">nullif!errorlevel! Equ 0 (set IP_ADDR_LOCAL=!TMP_I!GOTO:FOR_BREAK2) Else (Goto:loop_search_addr_pos))) setlocal Disableextensions:for_ Break2</span>rem return value assignment Set "%~1=%ip_addr_local%" Goto:exec_code:maincall:get_local_ip Ip_addr:exec_codeecho Local_ip=%ip_addr%pause</span>rem loop from (start value, recursive increment, last value) call for/l%%i in (10000001,1,10000010) do start HostClientTest.exe%ip_addr% 0%%i 192.168.12.63 30004</span>



Batch--work to get the native IP address and then execute a recurring startup script

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.