Share a folder during installation using Inno Setup
-
31-05-2021 - |
Question
Is it possible to create a network shared folders from an innosetup installation ?
With permissions and all ?
My application uses 2 Shared Folder in the clients network, everyone must be able to Read/Write to those Folders.
I Like to create this in the setup, to avoid doing it manually. Is IT Possible ?
La solution
You can use the Create
method of the Win32_Share Class.
try this sample
Const
FILE_SHARE = 0;
MAXIMUM_CONNECTIONS = 25;
function CreateShared(const Path, Name, Description : string):Integer;
var
FSWbemLocator: Variant;
FWMIService : Variant;
FWbemObjectSet: Variant;
begin
FSWbemLocator := CreateOleObject('WBEMScripting.SWBEMLocator');
FWMIService := FSWbemLocator.ConnectServer('', 'root\CIMV2', '', '');
FWbemObjectSet := FWMIService.Get('Win32_Share');
Result:=FWbemObjectSet.Create(Path, Name, FILE_SHARE, MAXIMUM_CONNECTIONS, Description);
end;
And use in this way
Err:= CreateShared('C:\Foo', 'MyShare','This is a public shared folder'); //0 indicates Success
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow