Batch wrapping problem/command line parameter wrapping arg ms-dos under DOS (CMD)

The problem of batch wrapping under DOS (CMD) I often write some DOS batch files. Since there are many and long references to commands in batch processing, it is not easy to distinguish them in one line, so I always want to find a way to write a command in a separate line. , I finally tried two methods today. 1. Under CMD, you can use ^ as a newline, similar to \ under Linux . For example:
start pemu.exe ^
-net nic,vlan=1,macaddr=00:aa:00:00:01:01 -net tap,vlan=1,ifname=tap1 ^
-net nic,vlan=2,macaddr =00:aa:00:00:01:02 -net tap,vlan=2,ifname=tap2 ^
-net nic,vlan=3,macaddr=00:aa:00:00:01:03 -net tap,vlan =3,ifname=tap3 ^
-serial [url=telnet::1007,server]telnet::1007,server[/url] ^
-m 128 FLASH802

 


二、用变量。举例如下:
@echo off
setlocal
set command_name=start pemu.exe
set nic1=-net nic,vlan=1,macaddr=00:aa:00:00:01:01 -net tap,vlan=1,ifname=tap1
set nic2=-net nic,vlan=2,macaddr=00:aa:00:00:01:02 -net tap,vlan=2,ifname=tap2
set nic3=-net nic,vlan=3,macaddr=00:aa:00:00:01:03 -net tap,vlan=3,ifname=tap3
set options=-serial [url=telnet::1007,server]telnet::1007,server[/url]
set parameter= -m 128 FLASH802
%command_name% %nic1% %nic2% %nic3% %options% %parameter%

 

 

 

I add:

It is best not to include % in the last parameter of the newline, otherwise it is easy to identify errors, and there is such a parameter in the last or middle parameter set.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326387376&siteId=291194637