Sunday, June 27, 2010

Enable or Disable File and Printer Sharing with snetcfg.exe

For a recent work project I needed to be able to be able to enable File and Printer Sharing on 2000+ machines for a few weeks while some software was deployed then disable File and Printer Sharing once the deployment was complete. I quickly found out that their was no group policy to easily do this and with a little google searching I found snetcfg.exe was the way to do this. Snetcfg.exe can be used to install/uninstall network protocols, services, and clients. Unfortunately, I found it really hard to find any documentation on this executable so I though I'd write up this short little post in hopes it would help someone else out with this delema...

Command I Used To Enable File and Printer Sharing
snetcfg.exe -c s -u MS_Server
snetcfg.exe -c s -i MS_Server
The first line above uninstalls File and Printer Sharing and the second reinstalls it. This ensures that File and Printer Sharing is installed and enabled. After the software was deployed I removed the second line from the start up script and File and Printer Sharing was once again disabled.

SNETCFG Command Line Help:
C:>snetcfg /?
snetcfg [-v] [-l ] -c -i
    -l provides the location of INF
    -c provides the class of the component to be installed
        p == Protocol, s == Service, c == Client
    -i provides the component ID
    The arguments must be passed in the order shown.
    snetcfg -l c:\oemdir\foo.inf -c p -i foo
    ...installs protocol 'foo' using c:\oemdir\foo.inf
    snetcfg -c s -i MS_Server
    ...installs service 'MS_Server'
snetcfg [-v] -q
    snetcfg -q MS_IPX
    ...displays if component 'MS_IPX' is installed
snetcfg [-v] -u
    snetcfg -u MS_IPX
    ...uninstalls component 'MS_IPX'
snetcfg [-v] -s
    -s provides the type of components to show
        a == adapters, n == net components
    snetcfg -s n
    ...shows all installed net components
snetcfg [-v] -b
    snetcfg -b ms_tcpip
    ...shows binding paths containing 'ms_tcpip'
General Notes:
    -v turns on the verbose mode
    -? Displays this help

Hope this helps some people... feel free to comment...