如何在Java中安装Windows驱动器? [英] How can I mount a windows drive in Java?
本文介绍了如何在Java中安装Windows驱动器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我们正在处理一些通过字母访问共享驱动器的遗留代码(例如f:\)。使用UNC表示法不是一种选择。我们的Java包装器应用程序将作为服务运行,作为第一步,我想在代码中显式映射驱动器。有没有人这样做过?
We are working with some legacy code that accesses a shared drive by the letter (f:\ for example). Using the UNC notation is not an option. Our Java wrapper app will run as a service, and as the first step, I would like to map the drive explicitly in the code. Has anyone done this?
推荐答案
考虑执行映射网络驱动器的DOS命令,如下面的代码所示:
Consider executing the DOS command that maps a network drive as in the following code:
String command = "c:\\windows\\system32\\net.exe use f: \\\\machine\\share /user:user password";
Process p = Runtime.getRuntime().exec(command);
...
查看有关净使用命令的详细信息:
See details on net use command:
The syntax of this command is:
NET USE
[devicename | *] [\\computername\sharename[\volume] [password | *]]
[/USER:[domainname\]username]
[/USER:[dotted domain name\]username]
[/USER:[username@dotted domain name]
[/SMARTCARD]
[/SAVECRED]
[[/DELETE] | [/PERSISTENT:{YES | NO}]]
NET USE {devicename | *} [password | *] /HOME
NET USE [/PERSISTENT:{YES | NO}]
这篇关于如何在Java中安装Windows驱动器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文