im制作了一个批处理文件,该文件创建了一个vbs脚本,该脚本发送关键输入,但这似乎不会在脚本中回显"%"。
echo set shell = createobject ("wscript.shell")> tempoary.vbs
echo shell.SendKeys "%f" >> tempoary.vbs
start tempoary.vbs
%
用于批处理文件中的变量,因此您的batch
程序正试图用其值替换变量%f
。当然,没有这样的变量,所以你什么都得不到。
您应该能够转义%
,因此它被视为文字百分比:
echo shell.SendKeys "%%f" >> tempoary.vbs
你应该这样写:
- 要逃离
)
这样的特殊字符,您应该添加一个carret^)
- 要转义像
%
这样的特殊字符,应该添加%%
进一步阅读: 转义字符
@echo off
(
echo set shell = createobject ("wscript.shell"^)
echo shell.SendKeys "%%f"
)> tempoary.vbs
start "" tempoary.vbs