Remove invalid share folder

I had several shared folders on my Windows 7 Home Premium (64-bit) system. Some of these folders no longer exist as they were located on a disk that I no longer use. Windows, however, still acts as though they exist, thus they still appear in the list of shares. I would like to remove these shares, but the system will not allow them.

After disabling the Share Wizard, I opened the "Shares" pane in Computer Management and found that the "Stop Sharing" option mentioned on many websites was not listed as an option for any of my ongoing shares, even the ones that still exist. My attempt to stop the share from the command line was also a failure. Using the command net share <sharename> /delete I received the error message "System error 3 has occurred. The system cannot find the path specified." Both of these actions were run with administrator privileges.

Is it possible to remove these shares without reconnecting the disk that contains the folders?


Solution 1:

Delete share:

reg delete "HKLM\SYSTEM\CurrentControlSet\Services\LanmanServer\Shares\Security" /v "<Share Name>" /f
reg delete "HKLM\SYSTEM\CurrentControlSet\Services\LanmanServer\Shares" /v "<Share Name>" /f

Restart File and printer sharing:

net stop LanmanServer /Y
net start LanmanServer /Y

view depend service:

sc EnumDepend LanmanServer | more

start service if need.