将环境变量设置为>'graterthan'windows 7批处理脚本

时间:2022-06-01 17:40:13

How to set Environment variable greater than symbol (>) in batch scripting in windows 7?

如何在Windows 7中的批处理脚本中将环境变量设置为大于符号(>)?

This is my script

这是我的剧本

set cmd=dir
set simb=>
set log=c:\Test\grater

%cmd% %simb% %log%

%cmd %% simb %% log%

Output on cmd is:

cmd上的输出是:

C:\Test>test.bat

C:\Test>set cmd=dir The syntax of the command is incorrect.

C:\ Test> set cmd = dir命令的语法不正确。

C:\Test>set simb=>

C:\Test>

Thanks

2 个解决方案

#1


2  

escape the > with double quotes:

使用双引号转义>:

set "simb=>"

#2


1  

Use a caret to escape the 'greater than' symbol:

使用插入符号来逃避“大于”符号:

set simb=^>

If you need to display the greater than symbol, you have to escape both a caret ^ and the >:

如果需要显示大于号,则必须同时删除插入符号^和>:

set simb=^^^>

or with double quotes:

或双引号:

set "simb=^>"

#1


2  

escape the > with double quotes:

使用双引号转义>:

set "simb=>"

#2


1  

Use a caret to escape the 'greater than' symbol:

使用插入符号来逃避“大于”符号:

set simb=^>

If you need to display the greater than symbol, you have to escape both a caret ^ and the >:

如果需要显示大于号,则必须同时删除插入符号^和>:

set simb=^^^>

or with double quotes:

或双引号:

set "simb=^>"