file batch- contest – command line to redirect to a file.txt

Issue

This Content is from Stack Overflow. Question asked by Francesco de Leonardis

If I write:
ipconfig /all >> c: list.txt
will be addressed the output to the C: List.txt file

If instead I write:

ECHO OFF
cls
Set /p rule_name = what name to the new rule?:
cls
Set /p ip_block = which ip you want to block “%rule_name%”?

Netsh Advfirewall Firewall Add rule Name = “%rule_name%” dir = in action = block remoteip = “%ip_block%”

This last line is first compiled by variables and then executed.

Therefore if in the variable rule_name I insert AAA
And in the IP_Block variable I insert 14.15.15.13
will become

Netsh Advfirewall Firewall Add rule name = AAA dir = in action = block remoteip = 14.15.15.13

And then it will be executed.

There is a way, to send the compiled row,

Netsh Advfirewall Firewall Add rule name = a dir = in action = block remoteip = 14.15.15.13

to a TXT file?



Solution

This question is not yet answered, be the first one who answer using the comment. Later the confirmed answer will be published as the solution.

This Question and Answer are collected from stackoverflow and tested by JTuto community, is licensed under the terms of CC BY-SA 2.5. - CC BY-SA 3.0. - CC BY-SA 4.0.

people found this article helpful. What about you?