I need to add Block Firewall Context Menu For .exe Files.
Code
Code: Select all
Reg Add "HKEY_CLASSES_ROOT\exefile\Shell\Firewall\Command" /T Reg_SZ /D "Elevate.exe CMD.exe /Q /C For %%%%A In (\"%%1\") Do Netsh Advfirewall Firewall Add Rule Name=\"%%~nA\" Dir=Out Action=Block Program=\"%%1\""
If filepath containing spaces it will simply throw out this error. To debug, I added
Code: Select all
& pause
Output
Code: Select all
A specified value is not valid.
Usage: add rule name=<string>
dir=in|out
..
Press any key to continue. . .
Code: Select all
A specified value is not valid.
Usage: add rule name=<string>
dir=in|out
..
Press any key to continue. . .
While debugging using Echo I found out that it doesn't have "" inside the
Code: Select all
Netsh Rule Name="" and Program=""
I have also tried escaping and adding double quotes. Still doesn't work.
Code: Select all
Reg Add "HKEY_CLASSES_ROOT\exefile\Shell\Firewall\Command" /T Reg_SZ /D "Elevate.exe CMD.exe /Q /C For %%%%A In (\"\"%%1\"\") Do Netsh Advfirewall Firewall Add Rule Name=\"\"%%~nA\"\" Dir=Out Action=Block Program=\"\"%%1\"\""