Question

so, I have a path in a .txt file made by my VB program. I need a batch to read it and place it in middle of a command. I have no idea how to do this, but I'll show you what I mean.

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

Sorry for being so unclear and I hope you get what I mean. And to the second question (not that important), how do I add a firewall exception with cmd?

Était-ce utile?

La solution

@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

?

Autres conseils

for /f "usebackq tokens=*" %%p in ("pathfile.txt") do (
    netsh firewall add allowedprogram program="%%~fp" name="%%~nxp" 
)
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top