I had some problems with the Windows Shares becoming unavailable at odd times, just randomly now and then. This meant I could no longer list and open my media files from my LG Home Theater or my Raspberry Pi.
I discovered that restarting a few services associated with Windows Folder Sharing solved the problem without the need to reboot.
This is a quick little script that I use to re-map my shared folders in Windows, including the disk shares (i.e. d$, e$) every night:
net stop LanmanServer /y
net start LanManServer
net start Browser
net start HomeGroupListener
Copy these lines in to a text-file using Notepad and save the file as “Sharemap.bat”, for example.
To set up an automatic scheduled job to run the script, open Task Scheduler (Start -> Run -> taskschd.msc) and set up a basic task: Right-click the folder area on the left and select “Create basic task”.
For the actions pane, select “Start a program” and point to the Sharemap.bat script.
For the triggers, you can set it to run every night at 5 in the morning or something similar.
If you’re using TrueCrypt and need to make disk shares (d$, e$ etc) map up after TrueCrypt mapping has taken place, create a trigger and set it to run “At log on”, with a delay that’s long enough to allow you to mount the TrueCrypt volumes before it runs (5-10 minutes maybe).
Alternatively, you can simply create a shortcut to “sharemap.bat” or save the file directly to your desktop and run it manually as needed.
How it works:
Stopping the LanmanServer service automatically stops the child services Browser and HomeGroupListener as well, automagically – so we only need to start those services, or at least I chose to do it that way to be on the safe side.
These network services are responsible for making Windows Shares available on the network, so it is sometimes necessary to restart them if there are any issues with finding shares, especially disk shares that are not automatically mapped by Windows, caused perhaps by delayed mounting from TrueCrypt or similar applications.