3

I am trying to enable files and printer sharing from command line, after some Googling I found that the right command to achieve this:

netsh advfirewall firewall set rule group="File and Printer Sharing" new enable=yes

This seems to be okay if the Windows language is English. However, in my French Windows this is the result from an administrative command prompt:

Aucune règle ne correspond aux critères spécifiés.

(English Translation: No rule matches the specified criteria)

I've also tried this command line:

netsh advfirewall firewall set rule group="Partage de fichiers et d'imprimantes" new enable=yes

But it didn't work as well and I get the same result as above.

3 Answers 3

2

The problem is with the apostrophe character in the command line.

  • The one that the keyboard displays is '
  • But the correct one for firewall rule is

So do a copy of a firewall rule title with that correct apostrophe character and then past it on a command shell.

Example:

  • Not Okay: netsh advfirewall firewall set rule group="Partage de fichiers et d'imprimantes" new enable=no
  • Okay: netsh advfirewall firewall set rule group="Partage de fichiers et d’imprimantes" new enable=no

The difference is between d and imprimantes.

It's not easy to script a batch with the correct apostrophe character. It returns an error. The apostrophe is correctly displayed in editor but misinterpreted on command prompt.

You can also use the keybooard input Alt+0146, which will display the correct character (found in the Windows characters map).

Topics related to:

On a command prompt, the two different apostrophe characters are displayed identically so it's not easy to found that this one character is messing up the entire command line, as displayed in 1

0

"File and printer sharing" firewall group can be enabled regardless of Windows language version with:

  1. netsh advfirewall with indirect string - index -28502 translates to name of the group (you can extract other available strings with indexes using eg. Nirsoft Resources Extract)

    netsh advfirewall firewall set rule group="@FirewallAPI.dll,-28502" new enable=Yes
    
  2. netsh firewall - deprecated since Windows Vista, but might be useful for Windows XP (no advfirewall or FirewallAPI.dll available)

    netsh firewall set service type=FileAndPrint mode=enable
    
-1

An alternative to the above answer: Since you seem to speak/type English just fine, you can change the display language to English through the Control Panel (or I'm sure via PowerShell, I just don't know the command), run that or any other command you want, then change it back to French once you're done.

1
  • 1
    Please provide specifics on how to do what you describe. I personally know how to do it, but the author, clearly does not. If you don't know the Powershell command, why do you mention, it might be possible? If you don't know the command how do you know if it even exists? (again I know the answers to these questions I am asking, you should edit your answer, and improve your answer)
    – Ramhound
    Dec 2, 2016 at 19:49

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .