Related Items  

Linux and Windows IT Support  

dedicated-technology-experts

Windows, Apple and Linux IT support and services.

For Software and Web Development.

Remove shared drive (using VBScript)

PrintE-mail

VBSccript_file_format_iconQ. Anytime I plug in my flash drive, Windows creates a share (eg. F$) that is accessible to people over the network. I can't permanently un-share that drive, but how would I speed up the process for removing it every time?

A. Yes, it is true that this share is accessible to people over the network, however, it is only accessible for anyone with admin rights and the person has to know that you have an F:\ drive plugged in in order to access it. In any case, this is how you would do that:

 

Using notepad (or my favourite - Notepad++) create a file on your desktop (eg. stop_share.vbs). Copy paste the contents below to that file:

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\" & strComputer & "\root\cimv2")
Set colShares = objWMIService.ExecQuery _
("Select * from Win32_Share Where Name = 'F$'")
For Each objShare in colShares
objShare.Delete
Next

Run that script any time you plug in your drive.

If you want to stop a share other than F$, just replace it in the code above. (It has to be the name of the share, not the actual folder or drive).

Add your comment

Your name:
Subject:
Comment:
  The word for verification. Lowercase letters only with no spaces.
Word verification:
yvComment v.1.24.0
   
Copyright © 1999 - 2024 Virtual Helpme | IT Services Catered to Your Business | Original Template: Allrounder