configurating windows 10 network share through .bat file

Page 2 of 3 FirstFirst 123 LastLast

  1. Posts : 14
    w10
    Thread Starter
       #11

    - - - Updated - - -

    Try3 said:
    jhugor,

    It's difficult to see in your posted screenshots but it looks to me as though the quotation marks have been turned into curvy quotation marks [which the Cmd window & Powershell do not recognise].
    This can often happen if you've pasted the code into a Word processor such as Word before saving it in order to run it.
    Copy H's code from this page straight into a Notepad file instead. That will not corrupt the quotation marks.


    No, sorry. I was looking at the first diagram. I can see them much more clearly in the second picture and they are not corrupted.



    All the best,
    Denis
    Thanks for your attention anyway!

    - - - Updated - - -

    Try3 said:
    jhugor,

    Knowing nothing about firewalls or using PowerShell with them, I wonder if it is a language problem.

    I suggest running this command in an Admin Command prompt window

    PowerShell Get-NetFirewallRule >"D:\Desktop\AllRulesForReview.txt"

    and post the results [which will be unnecessarily long purely to avoid using a better command that might cause errors].
    Do replace my D:\Desktop with the path to a folder of your own.
    My quotation marks are only there in case the path you write contains any spaces or special characters such as ampersands [&].


    I'm suggesting this test in case your Firewall rules use Portuguese equivalents of Network Discovery, File and printer sharing, ...


    Denis
    attach
    AllRulesForReview.txt


    thanks

    - - - Updated - - -

    hsehestedt said:
    Tell me if I am getting this wrong, but it looks to me like you are running the individual commands manually rather than running the commands from the batch file as is.

    The intent is to run the batch file as is as an administrator. You could add a line at the start to make it a little more readable like this:

    @echo off

    Just make that the very first line.

    I just tried it, and at least for me, it is working fine.
    configurating windows 10 network share through .bat file-screenshot_4.jpg

    configurating windows 10 network share through .bat file-screenshot_5.jpg

    I did as you said! thank you again
      My Computer


  2. Posts : 16,950
    Windows 10 Home x64 Version 22H2 Build 19045.4170
       #12

    I was right.
    Your commands are failing because your Windows firewall has DisplayGroup names in Portuguese so it does not have DisplayGroups called Network discovery or File and printer sharing.
    Many of your DisplayGroup names contain characters that do not render correctly in that text file. Perhaps that also affects using commands in Command prompt & PowerShell generally???

    [Hannes will be able to do better when he joins in]
    Run this command in an Admin Command prompt window to get a list of your firewall display groups
    Code:
    powershell "Get-NetFirewallRule | Select-Object DisplayGroup"
    It's a very long list because I do not know an easy way of removing duplicates. [My results list has 440 lines.]
    I suggest you scroll up & down in the Cmd window looking for the Portuguese for Network discovery & File and printer sharing
    You could save the list to a file as before
    Code:
    powershell "Get-NetFirewallRule | Select-Object DisplayGroup" >D:\Desktop\DisplayGroupsList.txt
    I've seen people refer to country codes when talking about using commands in foreign languages but it is not a subject I know anything about.
    If you can spot the Portuguese for Network discovery & File and printer sharing then I suggest you substitute them in the commands Hannes gave you.


    Best of luck,
    Denis
      My Computer


  3. Posts : 16,950
    Windows 10 Home x64 Version 22H2 Build 19045.4170
       #13

    I think you need
    Descoberta de Rede [instead of Network discovery]
    Compartilhamento de Arquivo e Impressora [File and Printer Sharing]
    I found them by searching for the relevant Group entry which is common to both our AllRulesForReview lists. Then I double-checked them with Google translate.
    [I also checked in your results that True/False & Private were always in English.]


    So that's, in an Admin Cmd window, for both lines that went wrong,
    Code:
    PowerShell "Set-NetFirewallRule -DisplayGroup 'Descoberta de Rede' -Enabled True -Profile Private"
    PowerShell "Set-NetFirewallRule -DisplayGroup 'Compartilhamento de Arquivo e Impressora' -Enabled True -Profile Private"
    BUT
    Do make a new system image first because if I'm wrong I might mess up your computer.


    Best of luck,
    Denis
      My Computer


  4. Posts : 14
    w10
    Thread Starter
       #14

    Try3 said:
    I was right.
    Your commands are failing because your Windows firewall has DisplayGroup names in Portuguese so it does not have DisplayGroups called Network discovery or File and printer sharing.
    Many of your DisplayGroup names contain characters that do not render correctly in that text file. Perhaps that also affects using commands in Command prompt & PowerShell generally???

    [Hannes will be able to do better when he joins in]
    Run this command in an Admin Command prompt window to get a list of your firewall display groups
    Code:
    powershell "Get-NetFirewallRule | Select-Object DisplayGroup"
    It's a very long list because I do not know an easy way of removing duplicates. [My results list has 440 lines.]
    I suggest you scroll up & down in the Cmd window looking for the Portuguese for Network discovery & File and printer sharing
    You could save the list to a file as before
    Code:
    powershell "Get-NetFirewallRule | Select-Object DisplayGroup" >D:\Desktop\DisplayGroupsList.txt
    I've seen people refer to country codes when talking about using commands in foreign languages but it is not a subject I know anything about.
    If you can spot the Portuguese for Network discovery & File and printer sharing then I suggest you substitute them in the commands Hannes gave you.


    Best of luck,
    Denis
    the commands worked using the words in Portuguese

    @echo off
    PowerShell "Set-NetConnectionProfile -Name (Get-NetConnectionProfile | Select-Object -ExpandProperty Name) -NetworkCategory Private"
    PowerShell "Set-NetFirewallRule -DisplayGroup 'Descoberta de Rede' -Enabled True -Profile Private"
    PowerShell "Set-NetFirewallRule -DisplayGroup 'Compartilhamento de Arquivo e Impressora' -Enabled True -Profile Private"
    pause
    I confirmed here and the changes worked

    however, these commands only change the private option... I did other commands here and managed to change the public, however, when the public is activated the private is deactivated.

    My question is the following.... using the mouse I can keep both the private and the public active, would it be possible to activate both using the commands below?

    @echo off
    PowerShell "Set-NetConnectionProfile -Name (Get-NetConnectionProfile | Select-Object -ExpandProperty Name) -NetworkCategory Private"
    PowerShell "Set-NetFirewallRule -DisplayGroup 'Descoberta de Rede' -Enabled True -Profile Private"
    PowerShell "Set-NetFirewallRule -DisplayGroup 'Compartilhamento de Arquivo e Impressora' -Enabled True -Profile Private"
    pause

    PowerShell "Set-NetConnectionProfile -Name (Get-NetConnectionProfile | Select-Object -ExpandProperty Name) -NetworkCategory Public"
    PowerShell "Set-NetFirewallRule -DisplayGroup 'Descoberta de Rede' -Enabled True -Profile Public"
    PowerShell "Set-NetFirewallRule -DisplayGroup 'Compartilhamento de Arquivo e Impressora' -Enabled True -Profile Public"
    pause
    I would like to remind you that we still have "all networks", but let's do one thing at a time so that I can follow the classes! :)

    configurating windows 10 network share through .bat file-screenshot_7.jpg

    thank very much
    Last edited by jhugor; 20 Feb 2024 at 09:20.
      My Computer


  5. Posts : 16,950
    Windows 10 Home x64 Version 22H2 Build 19045.4170
       #15

    By the way, when you are testing things you might usefully omit that
    @echo off
    because you want to see how the system responds to commands [even successful commands] until you are happy with the script.
    Personally, I never use it at all because I run all my scripts minimised to the Taskbar [so I don't care what gets shown] yet, if there is a problem, I can immediately open up the window and see everything with the hope of understanding & fixing the problem.


    Denis
      My Computer


  6. Posts : 14
    w10
    Thread Starter
       #16

    Try3 said:
    By the way, when you are testing things you might usefully omit that
    @echo off
    because you want to see how the system responds to commands [even successful commands] until you are happy with the script.
    Personally, I never use it at all because I run all my scripts minimised to the Taskbar [so I don't care what gets shown] yet, if there is a problem, I can immediately open up the window and see everything with the hope of understanding & fixing the problem.


    Denis
    great tip! thanks!
      My Computer


  7. Posts : 16,950
    Windows 10 Home x64 Version 22H2 Build 19045.4170
       #17

    "using the mouse I can keep both the private and the public active, would it be possible to activate both using the commands below"

    The answer is in
    Set-NetFirewallRule - MSLearn

    If I understand it correctly, you can use
    Code:
    PowerShell "Set-NetFirewallRule -DisplayGroup 'Compartilhamento de Arquivo e Impressora' -Enabled True -Profile Any"
    or
    Code:
    PowerShell "Set-NetFirewallRule -DisplayGroup 'Compartilhamento de Arquivo e Impressora' -Enabled True -Profile Private,Public"


    Denis
      My Computer


  8. Posts : 16,950
    Windows 10 Home x64 Version 22H2 Build 19045.4170
       #18

    jhugor said:
    I would like to remind you that we still have "all networks", but let's do one thing at a time so that I can follow the classes! :)

    configurating windows 10 network share through .bat file-screenshot_7.jpg
    You'll have to wait for H to come back to the forum.
    In the meantime, I suggest you find them in your own Firewall so you'll know which words to use in place of H's suggestions about the syntax to use.

    For all I know, they will use exactly the same syntax as
    PowerShell "Set-NetFirewallRule -DisplayGroup 'Compartilhamento de Arquivo e Impressora' -Enabled True -Profile Any"
    just with different parameter names [I don't even know what they are in English].

    Denis
      My Computer


  9. Posts : 14
    w10
    Thread Starter
       #19

    Try3 said:
    You'll have to wait for H to come back to the forum.
    In the meantime, I suggest you find them in your own Firewall so you'll know which words to use in place of H's suggestions about the syntax to use.

    For all I know, they will use exactly the same syntax as
    PowerShell "Set-NetFirewallRule -DisplayGroup 'Compartilhamento de Arquivo e Impressora' -Enabled True -Profile Any"
    just with different parameter names [I don't even know what they are in English].

    Denis
    everything works so far! I will now try the next step! :)

    So far my settings are like this!

    REG ADD "HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced" /V FileHideExt /T REG_WORD /D 00000000 /F

    PowerShell "Set-NetConnectionProfile -Name (Get-NetConnectionProfile | Select-Object -ExpandProperty Name) -NetworkCategory Private, Public"
    PowerShell "Set-NetFirewallRule -DisplayGroup 'Descoberta de Rede' -Enabled True -Profile Private, Public"
    PowerShell "Set-NetFirewallRule -DisplayGroup 'Compartilhamento de Arquivo e Impressora' -Enabled True -Profile Private, Public"

    REG ADD "HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer" /V IconUnderline /T REG_DWORD /D 3 /F
    REG ADD "HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer" /V ShellState /T REG_BINARY /D 240000001ea8000000000000000000000000000001000000130000000000000062000000 /F
    REG ADD "HKCU\Software\Microsoft\Internet Explorer\Main" /V "Anchor Underline" /T REG_SZ /D "no" /F

    taskkill /f /im explorer.exe
    start explorer.exe
    Now I want to try to configure all networks



    thank you very much
      My Computer


  10. Posts : 16,950
    Windows 10 Home x64 Version 22H2 Build 19045.4170
       #20

    Not
    Code:
    -Profile Private, Public"
    but
    Code:
    -Profile Private,Public"

    Denis
      My Computer


 

  Related Discussions
Our Sites
Site Links
About Us
Windows 10 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 10" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 12:20.
Find Us




Windows 10 Forums