Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Possible Duplicate:
How to create a shortcut using a batch script?

I would like to create shortcut files from some commands on a batch file.

Currently, I create .bat files for such each shortcut, but I would like to create .lnk files instead.

Any ideas?

share|improve this question

marked as duplicate by Dennis, CharlieRB, Mokubai, Indrek, 8088 Aug 22 '12 at 20:15

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

1  
You can either use a third-party program or create a temporary .vbs script. See the answers here: How to create a shortcut using a batch script? –  Dennis Aug 22 '12 at 19:25
1  
Do you mean create shortcuts to execute command prompt commands, or create a shortcut from a command prompt command? Edit: Oh, forgot what your title said. Yeah, what Dennis said is the only way to do it. I ran into this exact problem a while back. –  SaintWacko Aug 22 '12 at 19:43
add comment

1 Answer

up vote 1 down vote accepted

For starters, never use %username% to get a user's profile path.

You should use the environment variable USERPROFILE instead of the username, because sometimes the user profile path contains more than just the username (e.g. ., .000, .windows)

Back to your issue:

You cannot create a shortcut by just copy the exe file.

You can use a VBScript to create the shortcut:

https://groups.google.com/forum/?hl=en&fromgroups=#!msg/microsoft.public.scripting.vbscript/-RgWWk62aAE/qQ_u5sg8zOgJ

Alternatively:

Some free command line tools for shortcut creation:

Marty List's shortcut.exe http://optimumx.com/download/#Shortcut

MakeScut

http://www.scriptlogic.com/products/scriptingtoolkit/Default.asp

share|improve this answer
add comment

Not the answer you're looking for? Browse other questions tagged or ask your own question.