Problem while using "netsh firewall" in SP2


Recommended Posts

Hello everyone! Maybe some of you experts could help me...

I'm hoping to create a batch file to be used by remote clients who've installed SP2. The file's supposed to perform several successive netsh firewall commands to add known programs to the exceptions list.

For example - let's say I want to add Media Player Classic as such. What I'd have to do is use the following command:

netsh firewall add allowedprogram c:\program files\mplayerc.exe MediaPlayerClassic ENABLE

Maybe some of you experts have already noticed my problem, which is that space between "program" and "files".

The system won't accept that command as a valid command.

When I try running the program like so:

C:\>"C:\Program Files\mplayerc.exe"

everything works fine. But, alas, I can't use parantheses in the netsh command.

Also, I can't use the environment variable %ProgramFiles%. I get the same results.

What actually works is this:

netsh firewall add allowedprogram c:\progra~1\mplayerc.exe MediaPlayerClassic ENABLE

However, I really want to use the environment variable instead.

So - does anyone know how can I use the %ProgramFiles% variable so the the space between the words is not affecting my commands?

TIA everybody :)

I'm not a windows scripter, but:

%ProgramFiles% is probably replaced with "\Program Files" or "C:\Program Files", so you're still creating the same problem. Is there a seperate set of enviorment variables that use 8.3 filenames?

Besides, there has to be a better way to do it. if netsh doesn't allow spaces or ", than anyone who wants to use a dir that doesn't have a variable is screwed.

  CdCViRus said:
i think what you have to do is

netsh firewall add allowedprogram "c:\program files\mplayerc.exe" MediaPlayerClassic ENABLE

notice the quotes (")

You are right, it would work, BUT I want to do it with the environment variables and not by declaring a fixed path. So - any more ideas?

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.