Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Mapping drives in Java?

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
I am fairly new to Java and have a question regarding drive mappings in Windows. I am writing an application that has to be able to store the computers current drive mappings, and restore them later on before the program exits. So far I have not been able to find any information on how this could be done. I have an idea for restoring the drive mappings, but its useless if I can't get the mappings in the first place. Any help is appreciated. Thanks!
 
I don't know your situation but this sounds more like something you should be doing with Windows VB Scripting. The whole nature of Java doesn't allow it to access specific OS API like you would need. You could execute the command on the OS thru Java and parse the results to determine which drives are mapped if you absolutely insist on writing this in Java. I believe the Windows command you want is net use. So it would look like this:
Code:
Process p = Runtime.getRuntime().exec("net use");
p.waitFor();
You could than get the InputStream and parse the results you need.

Again I recommend you use Windows scripting. That is what it is there for. Java offers no advantage in this situation and actually makes it harder.
Wushutwist
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top