Disable Administrative Hidden Shares


  1. Posts : 5,330
    Windows 11 Pro 64-bit
       #1

    Disable Administrative Hidden Shares


    Administrative shares are hidden network shares that allow system administrators to have remote access to every disk volume on a network-connected system. These shares may not be permanently deleted but may be disabled. Windows users can use the net share command to view all of the shares (including the hidden shares) on your computer.

    With this batch script disable or enable Administrative Hidden Shares.

    Code:
    @Echo Off & Cls
    
    net sess>nul 2>&1||(powershell start cmd -ArgumentList """/c %~0""" -verb Runas & exit)
    
    Cls & Mode CON  LINES=11 COLS=80 & Color 0E & Title Created By FreeBooter
    Echo.
    Echo.
    Echo.
    Echo.       
    Echo         Do You Want To Disable Administrative Hidden Shares (Y/N)?   
    Echo.       
    Echo.
    Echo.
    
    
    Set /p input= RESPONSE: 
    If /i  Not %input%==Y (Goto :_Ex) Else (Goto :_Start) 
    
    :_Ex
    If /i Not %input%==N  (Goto :EOF) Else (Goto :_RegRestore)
    
    
    
    :_Start
    
    Reg Add "HKLM\SYSTEM\CurrentControlSet\Services\LanmanServer\Parameters" /v "AutoShareServer" /t REG_DWORD /d "0" /f > Nul
    Reg Add "HKLM\SYSTEM\CurrentControlSet\Services\LanmanServer\Parameters" /v "AutoShareWks" /t REG_DWORD /d "0" /f > Nul
    
    Cls & Mode CON  LINES=11 COLS=60 & Color 0E & Title Created By FreeBooter
    Echo.
    Echo.
    Echo.
    Echo.       
    Echo         Administrative Hidden Shares Disabled    
    Echo.       
    Echo.
    Echo. 
    ping -n 6 localhost >nul 
    
    
    CHOICE /C YN /M "Press Y to Reboot, N for exiting script."
    
    If %errorlevel% == 1 ( Shutdown /r /t 0) Else (Exit)
    
    
    
    :_RegRestore
    
    Reg Query "HKLM\SYSTEM\CurrentControlSet\Services\LanmanServer\Parameters" /v "AutoShareServer" > Nul
    
    If %ErrorLevel% EQU 1 Goto :EOF
    
    Reg Delete "HKLM\SYSTEM\CurrentControlSet\Services\LanmanServer\Parameters" /v "AutoShareServer" /f > Nul
    Reg Delete "HKLM\SYSTEM\CurrentControlSet\Services\LanmanServer\Parameters" /v "AutoShareWks" /f > Nul
    
    
    Cls & Mode CON  LINES=11 COLS=60 & Color 0E & Title Created By FreeBooter
    Echo.
    Echo.
    Echo.
    Echo.       
    Echo         Administrative Hidden Shares Enabled   
    Echo.       
    Echo.
    Echo. 
    ping -n 6 localhost >nul 
    
    
    CHOICE /C YN /M "Press Y to Reboot, N for exiting script."
    
    If %errorlevel% == 1 ( Shutdown /r /t 0) Else (Exit)
      My Computer


  2. Posts : 5,452
    Windows 11 Home
       #2

    You might add this to disable remote admin access to shares.
    Code:
    reg add "HKLM\Software\Microsoft\Windows\CurrentVersion\Policies\System" /v "LocalAccountTokenFilterPolicy" /t REG_DWORD /d "0" /f
      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:25.
Find Us




Windows 10 Forums