Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Need a Remote Script to Disable all machines in the drives Default Drives.

Posted on 2007-10-01
5
Medium Priority
?
227 Views
Last Modified: 2010-04-16
Hi,

I need a script with which i can disable the default specific shares only.
Say the Machine has C$,D$,E$,F$ I want the script to disable and never turn on after restart except C$.
I want the C$ to be as it is but none of the other drives to come back.

Regards
Sharath
0
Comment
Question by:bsharath
  • 3
  • 2
5 Comments
 
LVL 65

Accepted Solution

by:
RobSampson earned 2000 total points
ID: 20018897
Sharath, this would have to run on every computer at logon, because the share is always automatically recreated when the "Server" service is restarted, and there's nothing you can do about that:

'==================
strComputer = "."

Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")

Set colShares = objWMIService.ExecQuery _
    ("Select * from Win32_Share Where Name = 'D$' OR Name = 'E$' OR Name = 'F$' OR Name = 'G$'")

For Each objShare in colShares
    objShare.Delete
Next
'================

Regards,

Rob.
0
 
LVL 11

Author Comment

by:bsharath
ID: 20019322
If i place it in the local machine startup or profile startup will it work.
Will it not rremove the c$?
0
 
LVL 65

Expert Comment

by:RobSampson
ID: 20019351
Yes, just run it as is on yours, then check if those default shares are gone.  You should be able to re-enable them by restarting your Server service.

It won't remove C$ because it only looks for D$, E$, F$, and G$

Regards,

Rob.
0
 
LVL 11

Author Comment

by:bsharath
ID: 23209956
0
 
LVL 11

Author Comment

by:bsharath
ID: 23209957
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you haven’t already, I encourage you to read the first article (http://www.experts-exchange.com/articles/18680/An-Introduction-to-R-Programming-and-R-Studio.html) in my series to gain a basic foundation of R and R Studio.  You will also find the …
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
Suggested Courses

571 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