Automate Windows 7's file sharing and firewall settings
netsh
should be all you need to tweak the firewall. Here's the verbose documentation on how to use it for the firewall specifically (since it can be used for a lot of things non-firewall related). Here's a few examples that might help get you started:
# Allow Remote Desktop
netsh advfirewall firewall set rule group="Remote Desktop" new enable=Yes
# Allow File and Printer Sharing
netsh advfirewall firewall set rule group="File and Printer Sharing" new enable=Yes
Off the top of my head, I'm not sure how to affect the advanced sharing settings. I'm sure there's a way to do it though.
Related videos on Youtube
nhinkle
Updated on September 17, 2022Comments
-
nhinkle almost 2 years
I am working with my school to customize Windows 7 on some new laptops we are receiving. The laptops come with Windows 7 Professional already installed, and we do not need or want to reimage them. We would however like to customize the installation once it is in place, through a series of scripts. We will also be deploying these scripts to computers which have already been set up.
Most of the settings we wish to change can be done easily from the command line or with a registry file. However, there is one thing we keep getting hung up on: networking options. Is there any unattended way to set the Windows 7 networking configuration? We would like to set the following things automatically, which are found under
Control Panel > Network and Sharing Center > Advanced sharing settings > Home or Work network
:- Turn on network discovery
- Turn on printer and file sharing
- Turn off public folder sharing
- Turn on password protected sharing
- Use user accounts and passwords to connect to other computers
We also need to configure the firewall to allow the following exceptions:
- File and printer sharing
- Remote assistance
- Remote desktop
- Remote scheduled tasks management
- Remote service management
- Windows remote management
I've looked around, and can't find any way to change these things - I looked into
netsh
, registry settings, and even used RegMon to watch while I changed the values manually, all to no avail. Google hasn't offered up anything helpful so far. If anyone could provide some insight, I would very much appreciate it. I did find out that much of this is configurable with group policy, but because these computers are in a workgroup, not a domain, I don't know of any way to take advantage of that in an unattended manner. -
nhinkle about 14 yearsThanks. That successfully turned on and added exceptions for remote desktop and file and printer sharing. I did manage to find a way to do that by looking deeper in the
netsh
documentation. I still can't find any way to force it to require password-based authentication though. Any ideas there? -
nhinkle about 14 yearsOk - I got this to do most of what I needed, I just wasn't able to get the password settings how I wanted, but that's ok. I'm marking this as accepted, but if anyone thinks of anything else I'd love to hear it.