首页 > 解决方案 > 有没有办法在 bat 脚本中评估字符串文字中的变量?

问题描述

假设我有一个包含这样的字符串的变量......

set test=%%userprofile%%\Desktop\test.txt

如果你要回显 %test% 你会看到......

%userprofile%\Desktop\test.txt

一个人将如何获取该值并假设删除该文件?如果我执行以下操作...

del %test%

我得到...

"The system cannot find the path specified."

不知何故,我需要它来评估文字“%userprofile%”到用户的真实用户配置文件位置,以在他们的桌面上找到文件。有什么想法吗?

标签: batch-file

解决方案


推荐阅读