• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 230
  • Last Modified:

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

Hi,

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

Is there a way on logon that we can disable.

Regards
Sharath
0
bsharath
Asked:
bsharath
  • 2
  • 2
1 Solution
 
Netman66Commented:
This should work in a CMD file.

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



0
 
mb042Commented:
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.
0
 
Netman66Commented:
I should add that this may be necessary to run from a GPO using a Computer Startup script.

0
 
bsharathAuthor Commented:
Hi,

Where should i put these commands I just wabt to remove the d$, e$, F$ excluding Ipc$,Admin$ and C$
0
 
mb042Commented:
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

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now