Windows 7 sharing folder from command line, selecting users and triggering the "Apply" of changes
- by clintp
I have a drive that doesn't get mounted until after I log in. (A Truecrypt thumbdrive device, and no, I'm not making it a "System Favorite" to get around this.) I'd like to construct a batch file to share it once I've gotten it mounted because the sharing info doesn't seem to stick through a reboot.
From the GUI, I'd go into the folder Properties-Sharing. And then in Advanced Sharing I'd pick the name to share it as. And then under the "Share..." button I'd pick the users and the permissions I want to grant them. After "Apply" there's a pause -- I'm not sure what's happening here, but the dialog says "Sharing Items..." -- and then everything is okay.
From the command line, I've done:
net share MyFolder=F:\MyFolder
cacls F:\MyFolder /G FirstUser:F
cacls F:\MyFolder /G OtherUser:F
And this almost works. I can see the share on the network then, but nobody has permissions to do anything. If I go into the GUI and change anything (and I can see my command-line changes in there already) and press "Apply" I get the:
"Sharing Items....
This may take a few minutes"
Dialog... and then Voila! It works. I get the "Your folder is shared" dialog with the command-line changes I made, along with the GUI change that I made to trigger the "Sharing Items..." dialog. Everything's peachy.
Is a service being restarted? Which one?
What's triggering the sharing to take effect? And -- more importantly -- how do I do it from the command line?