I am trying to share a folder in java. I want to share a folder with several users. I use the following command:
net share sharefolder=<drive path> /GRANT:<username>,FULL
the above command shares the specified path folder with the username with FULL acess ie read and Write.
Can anyone help me out?
For multiple users, you can use the following command in your Java code
net share sharefolder=<drivepath> /GRANT:<username>,Full /GRANT:<username>,Full
You can add as many users as you need. Thank,
Use the 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()));