Logon scrript that can remove all the default shares except c$

Posted on 2007-10-19
Last Modified: 2010-04-16

Logon scrript that can remove all the default shares except c$.

Is there a way on logon that we can disable.

Question by:bsharath
    LVL 51

    Expert Comment

    This should work in a CMD file.

    net share Admin$ /d
    net share IPC$ /d

    LVL 4

    Expert Comment

    Not disable - but delete all shares

    reg delete HKLM\System\CurrentControlSet\Services\lanmanserver\Shares /f
    net stop "computer browser"
    net stop server
    net start "computer browser"

    kills all shares except admin shares

    You may have an issue if the user does not have enough registry rights to delete this key, so you may need to be creative with group policy or use the runas command.
    LVL 51

    Expert Comment

    I should add that this may be necessary to run from a GPO using a Computer Startup script.

    LVL 11

    Author Comment


    Where should i put these commands I just wabt to remove the d$, e$, F$ excluding Ipc$,Admin$ and C$
    LVL 4

    Accepted Solution

    Go to scheduled tasks and create a task for each share you want to delete
    (Wizard method:
    Pick any program (next)
    name it SHAREFIX1 (or something meaningfull with no spaces)
    choose When my computer starts (next)
    enter a user and password that has administrative rights on all workstations (next)
    tick Open advanced...  (Finish)
    Change the run line to: net share d$ /d (or whichever share)
    if the start line has a path, clear it.
    If you want to control share deletion using the logon script only, then untick Enabled. (OK)
    Now copy and paste this task in to your netlogon directory
    (repeat for each share you want to remove)
    now add the following lines to your logon script
    copy \\servername\netlogon\sharefix1.job %systemroot%\tasks
    schtasks /Run /TN sharefix1
    .....repeat for each sharefix


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    When we want to run, execute or repeat a statement multiple times, a loop is necessary. This article covers the two types of loops in Python: the while loop and the for loop.
    Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
    The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
    In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

    761 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    7 Experts available now in Live!

    Get 1:1 Help Now