Jump to content
ur

How to enable file sharing for all networks

Recommended Posts

ur

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

I mean programatically using AutoIT.

Share this post


Link to post
Share on other sites
JLogan3o13

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

 


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites
ur
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.

Share this post


Link to post
Share on other sites
JLogan3o13

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"


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites
ur
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.

Share this post


Link to post
Share on other sites
spudw2k
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

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

  • Similar Content

    • Fortitude
      By Fortitude
      Hello!
      I have made a program, that opens a folder, and then store the path ("C:\programFiles\etc") in a variable.
      Then i need to open the command panel as administrator, and write  in the stored path, and some other text.

      Can i somehow instantly copypaste the text i needed, instead of writing in the command panel with the Send commands?
       
      #RequireAdmin #include <MsgBoxConstants.au3> Global Const $sMessage = "Select a folder" ; Display an open dialog to select a file. Global $sFileSelectFolder = FileSelectFolder($sMessage, "") If @error Then MsgBox($MB_SYSTEMMODAL, "", "Nem választottál ki mappát!") Exit EndIf Global $Tiff_path = $sFileSelectFolder & "\TiffChecker_2_32" FileCopy( "C:\TiffChecker_2_32.exe" , $sFileSelectFolder) $CMD = $Tiff_path & " " & $sFileSelectFolder & " /s/d" Run("C:\WINDOWS\system32\cmd.exe") WinWaitActive("C:\WINDOWS\system32\cmd.exe") Send($CMD) Sleep(1000) Send("{ENTER}") sleep(1000) MsgBox(0,"Press OK", "Press OK to continue") FileCopy("C:\Tiffchecker.txt", $sFileSelectFolder) Also, how do i close the command panel, when the program is finished? (usually its under 1 second, so after the send i just put a Sleep function there)
    • nacerbaaziz
      By nacerbaaziz
      Hello my friends
      I have an inquiry after your permission
      I found a function to get the special line commands for any operation
      It requires the name of the process to be searched
      I want to use it to know the process
      Is this possible with this function
      Here is the code
       
      Func commandLineGet($proc, $strComputer=".")
      dim $array[1]
      local $ArrayNumber
      local $oWMI = ObjGet("winmgmts:{impersonationLevel=impersonate}!\\" & $strComputer & "\root\cimv2")
      local $oProcessColl = $oWMI.ExecQuery("Select * from Win32_Process where Name= " & '"'& $Proc & '"')
      local $Process
      For $Process In $oProcessColl
      $Process = $Process.Commandline
          ReDim $Array[UBound($Array)+1]
      $ArrayNumber = UBound($Array)-1
      $array[$ArrayNumber] = $Process
      Next
      $ArrayNumber = UBound($Array)-1
      $array[0] = $ArrayNumber
      return $array
      EndFunc
    • simy8891
      By simy8891
      Hi guys,
      It's been a while since I wrote my last message here and a while since I used AutoIt. I'm currently sort of desperate and I'm trying to find some help in regards of getting the network usage per process!
      I'm not interested in the total network usage of the NIC, but only on a specific PID's network utilization. They idea is to collect the amount of traffic uploaded and downloaded by a list of specific processes. So far Process Hacker and Process Explorer are capable of getting what I need, but I need to use these numbers in another script so they're sort of useless to me. I can't seem to find a way around it.
      Any idea, help is greatly appreciated.
      Thanks
    • BlazerV60
      By BlazerV60
      Hello all,
      I've written the code below which launches chrome in incognito mode and then proceeds to go to the autoit website.
      From my understanding, the Run() command is also supposed to output the PID number related to the application that got launched from the Run command.
      However when I run the below lines, it outputs a PID number that is different from the newly launched chrome browser's PID number, does anyone know why and possibly explain how I could retrieve the accurate PID number associated with the newly launched browser?
      Global $iPid = Run(@ComSpec & ' /c start chrome.exe https://www.autoitscript.com/forum/ -incognito' ,"", "") msgbox(0,"",$iPid) Thank you,
      Brian
    • badcoder123
      By badcoder123
      Anyone know how to access the information circled in the photo?
       

×