Java プログラムで、ユーザーの PC のスタートアップ フォルダの場所を確認するにはどうすればよいですか? Windowsのバージョンによって異なることは知っています。アプリが Windows で動作することだけが必要です。サンプルコードはありますか?
4035 次
2 に答える
1
これはうまくいくはずです:
System.getProperty("user.dir")
ここでは、システム プロパティの概要を示します。
http://download.oracle.com/javase/tutorial/essential/environment/sysprop.html
于 2010-12-30T21:38:17.523 に答える
1
ShellLink を使用すると、ショートカットを作成するのは非常に簡単です。https://github.com/BlackOverlord666/mslinks
メイヴン:
<dependency>
<groupId>com.github.vatbub</groupId>
<artifactId>mslinks</artifactId>
<version>1.0.5</version>
</dependency>
https://stackoverflow.com/a/38952899/4697928で回答を参照してください
private final String STARTUP_PATH = "/AppData/Roaming/Microsoft/Windows/Start Menu/Programs/Startup";
private void checkAutoStartPresent() {
File file = new File(System.getProperty("user.home") + STARTUP_PATH + "/YourShortcutFileName.lnk");
if (!file.exists()) { // shortcut not found
try {
ShellLink.createLink("/YourTargetProgramPath.exe", file.getAbsolutePath());
} catch (IOException e) {
e.printStackTrace();
}
}
}
于 2020-08-30T11:42:49.190 に答える