Reputation: 463
I am trying to share the folder programatically in java. I want to share the folder to multiple users. I use the following command:
net share sharefolder=<drive path> /GRANT:<username>,FULL
the above command share the given drive path folder with the username with FULL acess i.e read and Write.
Can anyone please help me out?
Upvotes: 2
Views: 1274
Reputation: 455
For multiple users you may use following command in your java code
net share sharefolder=<drivepath> /GRANT:<username>,Full /GRANT:<username>,Full
You can add as many users you need. Thank you,
Upvotes: 1
Reputation: 15896
Use java process to run your command:
String yourCommand = "net share sharefolder=<drive path> /GRANT:<username>,FULL";
Process p = Runtime.getRuntime().exec(yourCommand );
// To get the output of command
BufferedReader stdInput = new BufferedReader(new InputStreamReader(p.getInputStream()));
BufferedReader stdError = new BufferedReader(new InputStreamReader(p.getErrorStream()));
Upvotes: 2