Developing Matt

My Technical Journal

Don’t like to share?

leave a comment »

Someone asked me the other day how to programmatically unshare a device.  Here’s a vbscript

strComputer = “computername”
Set objWMIService = GetObject(“winmgmts:\\” & strComputer & “\root\cimv2”)
Set colShares = objWMIService.ExecQuery _
(“Select * from Win32_Share Where Name = ‘DeviceToUnshare(example:E$)'”)
For Each objShare in colShares
objShare.Delete
Next

Advertisements

Written by matt

July 25, 2007 at 12:40 pm

Posted in vbscript

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: