Creating New Shares

by May 11, 2009

You can use WMI to help create new file shares. This is the line you need:

md c:testfolder
([wmiclass]'Win32_Share').Create('C:testfolder', `
'myShare', 0, 5, 'A new share').ReturnValue

This will create a share for c:testfolder called myShare and allow 5 connections. Note that you may need admin privileges for this or else the return value of 2 will indicate "access denied" while a return code of 0 will indicate success.