批量转义百分号 [英] Batch Escape Percent sign

查看:135
本文介绍了批量转义百分号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,很难将环境变量传递给clip.exe,在常规命令提示符下它可以工作,但是一旦进入批处理文件,它就会失败。我尝试使用双 %% 和其他一些技巧进行转义。似乎什么都没用。

Hi Guys having a really hard time getting an environmental variable piped to clip.exe, in a regular command prompt it works but once in batch file it fails. I have tried escaping with double %% and a few other tricks. Nothing seems to work.

我正在尝试使用citrix环境变量%clientname%的输出进行裁剪.exe如下所示:

I am trying to pipe the output of the citrix environmental variable %clientname% to clip.exe like the following:

@echo off
echo %clientname% | clip


推荐答案

只需使用 ^ 符号可在命令行中转义字符:

Just use the ^ sign to escape the % char in command line:

C:\> echo ^%clientname^%

但是您需要使用符号可在批处理文件中转义符号:

But you need to use the % sign to escape a % symbol in a batch file:

@echo %%clientname%%

这篇关于批量转义百分号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆