How to Block .exe in Windows Firewall with batch file (script)

I am new to StackExchange so apologies in advance if I post anything that does not confirm to the rules.

I would like to be able to block a program (.exe) in the windows firewall by running a batch file.

I have had a dig around the internet and narrowed my search to the below script for achieving what I want. However, it does not seem to work when I run it in .bat format.

Is anyone able to assist please. Many thanks.

for %%G in (“C:Program FilesExampleExampleexample*.exe”) do (
netsh advfirewall firewall add rule name=”Blocked With Batchfile %%G” dir=in action=block program=”%%G” enable=yes profile=any netsh advfirewall firewall add rule name=”Blocked With Batchfile %%G” dir=out action=block program=”%%G” enable=yes profile=any
)