Jump to content

Recommended Posts

Posted

How to enable file sharing for all public,private,work,home networks.

I mean programatically using AutoIT.

  • Moderators
Posted

I just had to do this for a customer, using nvspbind.exe. Here is what I did; you should be able to modify it easily for your needs:

Func _turnOnFilePrint()
    Local $oWMI = ObjGet("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")
        If IsObj($oWMI) Then
            Local $oNICs = $oWMI.ExecQuery("Select * from Win32_NetworkAdapter WHERE NetConnectionStatus = '2'")
                If $oNICs.Count > 0 Then
                    For $sNic In $oNICs
                        ShellExecuteWait(@TempDir & "\nvspbind.exe", '-e "' & $sNic.Description & '" ms_server', Default, Default, @SW_HIDE)
                    Next
                Else
                    Return 1
                EndIf
        Else
            Return 1
        EndIf

    Return 0
EndFunc

 

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Posted
14 hours ago, JLogan3o13 said:

I just had to do this for a customer, using nvspbind.exe. Here is what I did; you should be able to modify it easily for your needs:

Func _turnOnFilePrint()
    Local $oWMI = ObjGet("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")
        If IsObj($oWMI) Then
            Local $oNICs = $oWMI.ExecQuery("Select * from Win32_NetworkAdapter WHERE NetConnectionStatus = '2'")
                If $oNICs.Count > 0 Then
                    For $sNic In $oNICs
                        ShellExecuteWait(@TempDir & "\nvspbind.exe", '-e "' & $sNic.Description & '" ms_server', Default, Default, @SW_HIDE)
                    Next
                Else
                    Return 1
                EndIf
        Else
            Return 1
        EndIf

    Return 0
EndFunc

 

The above command is not enabling sharing.

Could you please help me on this.

Posted
On 8/5/2016 at 3:39 PM, JLogan3o13 said:

Did you run it with #RequireAdmin? It just worked for me for 3000+ computers, so you're going to have to be more specific than "it doesn't work"

I am using #RequireAdmin.Downloaded  nvspbind.exe  and targeted to @ScriptDir and ran the above code.

But it is not enabling any sharing in the network settings.

Posted (edited)
On 8/5/2016 at 3:09 AM, JLogan3o13 said:

Did you run it with #RequireAdmin? It just worked for me for 3000+ computers, so you're going to have to be more specific than "it doesn't work"

Were you just binding the protocol, or were you enabling File & Print Sharing for each network location profile?

@ur Toggling the "Turn on/off file and printer sharing" for a given network location profile (Private, Public, Work) seems to change the firewall configuration (WF.msc)

This looks like a potential starting place: https://msdn.microsoft.com/en-us/library/aa364721.aspx

Edited by spudw2k

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
×
×
  • Create New...