Button to launch Advanced Sharing & Share Permissions dialog

I have various folders which I share over my LAN, but I don't like to keep them shared all the time. Currently, I right-click the folder I want to share and select Properties. On the Properties dialog, I go to the Sharing tab and click the Advanced Sharing button, which brings up the Advanced Sharing dialog. On the Advanced Sharing dialog, there is a Permissions button which becomes enabled when you tick the Share this folder checkbox. On the Permissions dialog.

When sharing I usually prefer to limit the number of simultaneous users to 2, remove sharing permissions for Everyone and add my custom User Group with Full Control sharing permissions.

This is obviously a bit tedious having to go through several dialogs, so I wanted to be able to select a one (or more) folders, click a button "Share", and enter Admin password on elevation dialog, which would achieve the above.

I would also want a corresponding button to unshare them.

Anyone know how to do this ?

After a minute on google :grin:, I came up with "net share" which seems to do most of what I want, except change folder share permissions.

A bit more googling came up with the icacls tools which should take care of the share permissions issue.

Further investigation indicates that icacls handles file system permissions rather than share permissions. Fortunately, net share appears to handle share permissions as well.

EDIT: icacls may be able to handle share permission, but not sure. Either way, it doesn't matter for these buttons.

Below is my solution (replace "{USERNAME | GROUPNAME}" with the actual user/group name who you want to share with. If the name has spaces in it, you need to surround it with quotes). Few minor issues:

  1. "runmode:hide doesn't appear to work, as DOS window can still be seen (one for each folder selected). Any ideas ?
  2. Lister icons for selected folders aren't automatically updated to show they are shared/un-shared. A manual refresh (ie. F5) is required. I tried putting "Go REFRESH=All" after the net command, but the refresh happens before the folders are shared/un-shared. Any ideas ?
  3. Multiple instances of net.exe process run in parallel (one for each folder being shared), rather than launching sequentially (although I'm not sure if this is an issue). Is it possible to get Opus to run them sequentially rather than in parallel ?

<?xml version="1.0"?> <button backcol="none" display="both" textcol="none"> <label>Share Folder(s)</label> <tip>Share selected folders with {USERNAME | GROUPNAME} group</tip> <icon1>#mapnetworkdrive</icon1> <function type="normal"> <instruction>@admin</instruction> <instruction>@nodeselect </instruction> <instruction>@dironly</instruction> <instruction>@runmode:hide</instruction> <instruction>net share {file$}={filepath$|noterm} /USERS:2 /CACHE:no /GRANT:&quot;{USERNAME | GROUPNAME}&quot;,FULL</instruction> </function> </button>

<?xml version="1.0"?> <button backcol="none" display="both" textcol="none"> <label>Stop Sharing Folder(s)</label> <tip>Stop sharing selected folders</tip> <icon1>#disconnectnetworkdrive</icon1> <function type="normal"> <instruction>@admin</instruction> <instruction>@nodeselect </instruction> <instruction>@dironly</instruction> <instruction>@runmode:hide</instruction> <instruction>net share {file$} /DELETE</instruction> </function> </button>

It's
@runmode hide
not
@runmode:hide
At least I've always used the former.

[quote="Xyzzy"]It's
@runmode hide
not
@runmode:hide
At least I've always used the former.[/quote]Thanks Xyzzy! That did the trick. Just need to find a solution to the other two problems (#2 in particular is annoying).

Try adding @sync: before the net command.

@sync: net share ...

[quote="leo"]Try adding @sync: before the net command.

@sync: net share ...[/quote]That doesn't appear to work, as Process Explorer still shows multiple processes being launched. However, that might just be because they are only running for a short time, and PE doesn't update the display quick enough. I'll do some more testing to confirm.

BTW, how come @sync isn't documented ?