逃生"双引号"里面批的输入参数 [英] Escape "double quotes" inside batch's input parameters
问题描述
我要运行批处理脚本它需要一个参数如下(路径)
I want to run the following in batch script where it takes an argument (a path)
runas /user:abc "icacls %1 /grant Everyone:(F) /T"
但参数%1
已经包含了一个(因为它是一个路径,通过对上下文菜单中的Send为了 - 我没有过这么多的控制)。
所以,当命令批处理脚本运行它运行如下:
but the argument %1
already contains a "
(because it's a path, passed on by context menu's Send To - I don't have much control over this).
So when the command runs in batch script it runs like this:
runas /user:abc "icacls "c:\folder" /grant Everyone:(F) /T"
所以,很显然,我需要在躲避 S按
%1
创建。如何执行字符串操作%1
,使得它逃过了引号?
So obviously I need to escape the "
s created by %1
. How do I perform string manipulation over %1
such that it escaped the quotes?
推荐答案
您应该能够使用 \\
的在这里是与您可能会发现有用一些其他的转义字符网站
You should be able to use \"
Here is a site with a few other escape characters that you might find useful
要执行字符串替换:
set temp=%1
set temp=%temp:"=\"%
echo %temp%
这篇关于逃生"双引号"里面批的输入参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!