简体   繁体   中英

Open password protected folder in file explorer using java app

I would like to open a password protected NAS folder through IP address in windows 10 file explorer. I write my code in Java Eclipse.

I have a small code that opens the folder but then I have to write in username and password manually.

Is there a way to open the folder in file explorer already authenticated with given username and password?

Authentication window

Thank you in advance for your help!

Runtime.getRuntime().exec("explorer.exe /n, /e, "+ip);

Using "net use" command I can teach the computer the username and admin for the authentication, then simply open the folder using explorer.exe

String ip = "\\\\192.168.10.199";
String user = "admin";
String pw = "admin";

Runtime.getRuntime().exec("net use " + ip + " /user:" + user + " " + pw);
Runtime.getRuntime().exec("explorer.exe /n, /e, "+ip);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM