简体   繁体   中英

Is it possible to write a batch file to assign shortcutkey to a .jar file in Windows

as explained in my question, yupp, I'm looking for a yes/no answer to it, if possible could someone direct me to a way to do so?

Basically, I'm aware of the thread " How to set up keyboard shortcuts from windows command line? " but nircmd's shortcutkey cmd as suggested in the thread isn't working so i'm looking for an alternative to do so.

TO CLARIFY Do note that I'm aware of the manual way to assign a shortcutkey in windows like clicking into properties and setting it, but i'm looking for a cmd line or .bat way :) THANKS!

Do advise :) thanks in advance!!!

You can't do it directly using cmd.exe commands (without 3rd party tools) but you can create a small VBScript script for that.

Methods for Shell interoperability are in the ActiveX object WScript.Shell and method you need is CreateShortcut :

Shell = new ActiveXObject("WScript.Shell");
link = Shell.CreateShortcut("Shortcut file name.lnk");
link.TargetPath = "path to your program";
link.Arguments = "program arguments";
link.Description = "shortcut description";
link.Hotkey = "CTRL+SHIFT+M";
link.Save();

Save this code in a file .vbs file and execute it once, it'll create your shortcut and it'll be available immediately. Note that there are more properties you can set (icon, window style, working directory and so on), just refer to MSDN for WshShortcut object documentation.

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