Hi everyone,

I used to create shortcuts with IWshRuntimeLibrary in C#, but now i am trying to create in java, which i couldn't found via googling.

Can anyone show me the shortcut path of wisdom and illumination? :)

Recommended Answers

All 4 Replies

Use the ProcessBuilder class to run the (free) XXMKLINK program?

Use the ProcessBuilder class to run the (free) XXMKLINK program?

Thanks James,

Even though, i don't want to use an external executable file to process, i guess this is the best alternative for now (with running in quiet mode "/q")...

try this

String script = "Set sh = CreateObject(\"WScript.Shell\")"
+ "\nSet shortcut = sh.CreateShortcut(\"D:/temp/Shortcut.lnk\")"
+ "\nshortcut.TargetPath = \"D:/some path to file\""
+ "\nshortcut.Save";

File file = new File("d:/temp/temp.vbs");
FileOutputStream fo = new FileOutputStream(file);
fo.write(script.getBytes());
fo.close();
//Runtime.getRuntime().exec("wscript.exe D:/temp/crear-acceso-directo.vbs");
Runtime.getRuntime().exec("wscript.exe " + file.getAbsolutePath() );

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.