I need to do following using Java code: 1. win+R (run) 2. Paste a shared folder location say: "\10.10.10.0\aaa\bbb" 3. need to fill user id and pwd in the authentication window
I wrote following code ...
public void accessSharedPath(String path) {
Authenticator.setDefault(new SharedPathAuthenticator());
try {
new ProcessBuilder("explorer.exe", path1).start();
} catch (IOException e) {
e.printStackTrace();
}
}
class SharedPathAuthenticator extends Authenticator {
private String userName = "xxxx";
private char[] password = { 'x', 'x', 'x', 'x', 'x', 'x', 'x' };
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(userName, password);
}
}
Now the problem is if in my machine the authentication has been done previously then it works fine (even without the Authenticator), but when i remove the saved passord and run this it opens My Document folder.