Sign in to follow this  
Followers 0
Tentaal

Enable/Diable network comonents

3 posts in this topic

Hi,

Someone has a function to disable or enable Network components as "Client for Microsoft Network" or "File and Print Sharing"?.

Thanks!

Share this post


Link to post
Share on other sites



Have you looked into the Group Policy settings? i.e. command prompt "mmc"

Share this post


Link to post
Share on other sites

Someone has a function to disable or enable Network components as "Client for Microsoft Network" or "File and Print Sharing"?.

I coded myself a script to change between my work-settings (no FP-sharing, a proxy, automatic IP-address, some printer) and my home-settings (FP-sharing, no proxy, fixed IP-address, other printer). The script is quite large, but I'll quote (the somewhat modified) part to enable/disable "File and Printer Sharing" here. It isn't too difficult to modify the script to do the same for the "Client for Microsoft Networks"... :)

#NoTrayIcon
AutoItSetOption('PixelCoordMode',   0)
AutoItSetOption('MouseCoordMode',   0)
AutoItSetOption('WinWaitDelay',     0)
AutoItSetOption('SendKeyDelay',     0)

Global  $WinShell = ObjCreate('shell.application'), $ControlPanel = 3, $NetConTitle = 'Network Connections', $SharingIsOn = 0, _
        $NetWorkName = 'ENTER THE NAME OF YOUR NETWORK HERE', $SharingShouldBeOn = 0    ;Change last value to 1 if FPS should be on...

For $ControlPanelItem in $WinShell.NameSpace($ControlPanel).Items   ;Get all ControlPanel items
    If $ControlPanelItem.Name = $NetConTitle Then   ;Search for the item representing the Network Connections
        For $NetworkConnection In $ControlPanelItem.GetFolder.Items ;Get all Network Connections items
            If $NetworkConnection.Name = $NetWorkName Then ExitLoop(2)  ;Search for the item representing your Network
        Next
    EndIf
Next
$NetworkConnection.InvokeVerb("P&roperties")    ;Invoke the properties of your Network
$FPS_Item = ControlListView($NetworkName, '', 16012, 'FindItem', 'File and Printer Sharing for Microsoft Networks') ;Zerobased number for the FPS item
If WinWaitActive($NetWorkName & ' Properties', 'your computer') And Not PixelGetColor(35, (158 + 17 * $FPSItem)) Then $SharingIsOn = 1  ;See if FPS is enabled
WinMove($NetWorkName & ' Properties', '', @DesktopWidth - 1, @DesktopHeight - 1)    ;And move the Properties screen
Send('{Down & ' & $FPS_Item & '}')  ;Give the FPS item focus
If Not ($SharingIsOn = $SharingShouldBeOn) Then Send('{SPACE}') ;Toggle it if needed
Send('{TAB 5}{ENTER}')  ;And close the Properties screen

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0