Using the command prompt
To enable or disable the File and Printer Sharing exception
• Type the following at the command prompt, and press ENTER:
netsh firewall set service type = fileandprint mode = mode
Specifies whether to enable or disable the exception.
If you get an "Access Denied" message when you run a command, you do not have administrative rights to configure Windows Firewall. If you get an "Ok" message but the command does not take effect, the setting might be managed by Group Policy.