In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
For cycle of Windows Bat 1. Basic usage of For cycle. 1.1 format
In the cmd window:
FOR% variable IN (set) DO command [command-parameters]
In the Bat file:
FOR% variable IN (set) DO command [command-parameters]
Note: in the cmd window, the form variable I after for must be referenced by a single percent sign, that is,% I, while in a batch file, the reference form variable I must use a double percent sign, that is,% I.
What are the basic elements of a For statement:
1. For, in and do are the keywords of the for statement, and none of them are indispensable.
2.% I is a reference to a formal variable in a for statement, which must appear even if it does not participate in the execution of the statement after do.
3. After in, the parentheses before do cannot be omitted
4. Set represents a string or variable, and command represents a string, variable or command statement
1.2 View Windows help documentation
Use for /? You can view
1.3 practical examples
1.3.1 list all txt files under the current path.
For I in (? .txt) do echo'I'
1.3.2 text parsing shows for / f usage.
1) assign the value of the command line to the variable.
For / f% I in ('wmic ComputerSystem get Manufacturer ^ | find / v "Manu" ^ | findstr.') Do (set type=%i)
2) use "delims=" to specify the delimiter, and / f defaults to a space or Table key as the delimiter.
For / f "delims=,"% I in ('wmic ComputerSystem get Manufacturer ^ | find / v "Manu" ^ | findstr.') Do (set type=%i)
Ps: the structure of the IF statement
For / f% I in ('wmic ComputerSystem get Manufacturer ^ | find / v "Manu" ^ | findstr.') Do (set type=%%i) if% type%== "HP" (reg add "HKEY_LOCAL_MACHINE\ SYSTEM\ CurrentControlSet\ Control\ Terminal Server" / v fDenyTSConnections / t REG_DWORD / d 0 / f): open the remote desktop service reg add "HKEY_LOCAL_MACHINE\ SYSTEM\ CurrentControlSet\ Control\ Terminal Server\ Wds\ rdpwd\ Tds\ tcp" / v PortNumber / t REG_DWORD / d 0x0000b239 / freg add "HKEY_LOCAL_MACHINE\ SYSTEM\ CurrentControlSet\ Control\ Terminal Server\ WinStations\ RDP-Tcp "/ v PortNumber / t REG_DWORD / d 0x0000b239 / f) else if% type%==" Dell "(reg add" HKEY_LOCAL_MACHINE\ SYSTEM\ CurrentControlSet\ Control\ Terminal Server "/ v fDenyTSConnections / t REG_DWORD / d 0 / f: open the remote desktop service reg add" HKEY_LOCAL_MACHINE\ SYSTEM\ CurrentControlSet\ Control\ Terminal Server\ Wds\ rdpwd\ Tds\ tcp "/ v PortNumber / t REG_DWORD / d 0x0000b275 / freg add" HKEY_LOCAL_MACHINE \ SYSTEM\ CurrentControlSet\ Control\ Terminal Server\ WinStations\ RDP-Tcp "/ v PortNumber / t REG_DWORD / d 0x0000b275 / f) else (echo your server type does not match the specified port number)
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.