如何将文本文件中的文本导入“字符串”?批| 。蝙蝠

时间:2014-02-28 09:06:46

标签: batch-file text firewall

所以,我的VB程序生成的.txt文件中有一个路径。我需要一个批处理来读取它并将其放在命令的中间。 我不知道该怎么做,但我会告诉你我的意思。

`add a firewall exception "path in textfile.txt" all configurations'

很抱歉这么不清楚,我希望你明白我的意思。对于第二个问题(不是那么重要),如何使用cmd添加防火墙例外?

2 个答案:

答案 0 :(得分:0)

@echo off
for /f "usebackq tokens=* delims=" %%P in ("pathFile.txt") do set "path_to_exc=%%~P"
netsh firewall add allowedprogram "%path_to_exc%" "My_Application" ENABLE

答案 1 :(得分:0)

for /f "usebackq tokens=*" %%p in ("pathfile.txt") do (
    netsh firewall add allowedprogram program="%%~fp" name="%%~nxp" 
)
相关问题