Closed

Creating desktop shortcuts from the command line?

Archived from groups: microsoft.public.windowsxp.general (More info?)

Does anyone know how to create a desktop shortcut to an executable using the
command line/batch file?

I've tried: copy c:\application.exe c:\documents and
settings\%username%\desktop\shortcut to application.lnk

and it doesn't seem to work. It creats an icon on the desktop, but clicking
it does nothing. I've tried copy and xcopy and all the switches, but none
seem to create shortcuts. I've looked at other shorcuts (automatically
created) and they all seem to be in the form of: shortcut.lnk

I am stumped. Any 411 would be great. Thanks...
17 answers Last reply
More about creating desktop shortcuts command line
  1. Archived from groups: microsoft.public.windowsxp.general (More info?)

    Curious as to why you want to do this when drag and drop in Windows
    works so easily to create shortcuts?

    Bill

    "Peter A. Berger Jr." <PeterABergerJr@discussions.microsoft.com> wrote
    in message news:FDE59A51-0D1E-4F1B-A83B-6616F116689B@microsoft.com...
    Does anyone know how to create a desktop shortcut to an executable using
    the
    command line/batch file?

    I've tried: copy c:\application.exe c:\documents and
    settings\%username%\desktop\shortcut to application.lnk

    and it doesn't seem to work. It creats an icon on the desktop, but
    clicking
    it does nothing. I've tried copy and xcopy and all the switches, but
    none
    seem to create shortcuts. I've looked at other shorcuts (automatically
    created) and they all seem to be in the form of: shortcut.lnk

    I am stumped. Any 411 would be great. Thanks...
  2. Archived from groups: microsoft.public.windowsxp.general (More info?)

    Peter A. Berger Jr. wrote:
    > Does anyone know how to create a desktop shortcut to an executable using the
    > command line/batch file?
    >
    > I've tried: copy c:\application.exe c:\documents and
    > settings\%username%\desktop\shortcut to application.lnk
    >
    > and it doesn't seem to work. It creats an icon on the desktop, but clicking
    > it does nothing. I've tried copy and xcopy and all the switches, but none
    > seem to create shortcuts. I've looked at other shorcuts (automatically
    > created) and they all seem to be in the form of: shortcut.lnk
    >
    > I am stumped. Any 411 would be great. Thanks...

    No way to do it using standard batch commands that I know of. You can do
    this using windows script, either vbscript or javascript. For examples see
    http://msdn.microsoft.com/library/en-us/script56/html/wsconcreatingshortcut.asp.
    --
    Tom Porterfield
    MS-MVP Windows
    http://support.telop.org

    Please post all follow-ups to the newsgroup only.
  3. Archived from groups: microsoft.public.windowsxp.general (More info?)

    The reason is that we have a custom VB application that installs itself but
    the programmers never thought to make life easy and put a shortcut to it
    anywhere. I'm scripting an old version uninstall, new version install and
    shortcut creation. I know that "create shortcut" is so easy via mouse -- but
    my end users are dumber than the mouse itself. ;)

    "Bill Sharpe" wrote:

    > Curious as to why you want to do this when drag and drop in Windows
    > works so easily to create shortcuts?
    >
    > Bill
    >
    > "Peter A. Berger Jr." <PeterABergerJr@discussions.microsoft.com> wrote
    > in message news:FDE59A51-0D1E-4F1B-A83B-6616F116689B@microsoft.com...
    > Does anyone know how to create a desktop shortcut to an executable using
    > the
    > command line/batch file?
    >
    > I've tried: copy c:\application.exe c:\documents and
    > settings\%username%\desktop\shortcut to application.lnk
    >
    > and it doesn't seem to work. It creats an icon on the desktop, but
    > clicking
    > it does nothing. I've tried copy and xcopy and all the switches, but
    > none
    > seem to create shortcuts. I've looked at other shorcuts (automatically
    > created) and they all seem to be in the form of: shortcut.lnk
    >
    > I am stumped. Any 411 would be great. Thanks...
    >
    >
    >
  4. Archived from groups: microsoft.public.windowsxp.general (More info?)

    Peter A. Berger Jr. wrote:

    > Does anyone know how to create a desktop shortcut to an executable
    > using the command line/batch file?
    >
    > I've tried: copy c:\application.exe c:\documents and
    > settings\%username%\desktop\shortcut to application.lnk
    >
    Hi,

    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. <username>.<domain>, <username>.000,
    <username>.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:
    http://groups.google.co.uk/group/microsoft.public.scripting.vbscript/msg/e8cc3cc8e6ee0fa9?dmode=source&hl=en

    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


    --
    torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway
    Administration scripting examples and an ONLINE version of
    the 1328 page Scripting Guide:
    http://www.microsoft.com/technet/scriptcenter/default.mspx
  5. Archived from groups: microsoft.public.windowsxp.general (More info?)

    The solution I ended up using was Wscript to make a .vbs file. Using the:

    set WshShell = WScript.CreateObject("WScript.Shell")
    strDesktop = WshShell.SpecialFolders("AllUsersDesktop")
    set oShellLink = WshShell.CreateShortcut(strDesktop & "\shortcut name.lnk")
    oShellLink.TargetPath = "c:\application folder\application.exe"
    oShellLink.WindowStyle = 1
    oShellLink.IconLocation = "c:\application folder\application.ico"
    oShellLink.Description = "Shortcut Script"
    oShellLink.WorkingDirectory = "c:\application folder"
    oShellLink.Save


    did the trick.
    THANKS ALL!

    "Torgeir Bakken (MVP)" wrote:

    > Peter A. Berger Jr. wrote:
    >
    > > Does anyone know how to create a desktop shortcut to an executable
    > > using the command line/batch file?
    > >
    > > I've tried: copy c:\application.exe c:\documents and
    > > settings\%username%\desktop\shortcut to application.lnk
    > >
    > Hi,
    >
    > 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. <username>.<domain>, <username>.000,
    > <username>.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:
    > http://groups.google.co.uk/group/microsoft.public.scripting.vbscript/msg/e8cc3cc8e6ee0fa9?dmode=source&hl=en
    >
    > 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
    >
    >
    > --
    > torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway
    > Administration scripting examples and an ONLINE version of
    > the 1328 page Scripting Guide:
    > http://www.microsoft.com/technet/scriptcenter/default.mspx
    >
  6. i tried the command you make and its says syntax error..so I've change the syntax and its working fine. test on win xp and vista .but you may test it on win 2000.

    original syntax:

    copy c:\application.exe c:\documents and settings\%username%\desktop\shortcut to application.lnk

    New syntax for win xp"

    copy "c:\application.exe" "c:\documents and settings\%username%\desktop\shortcut to application.exe"

    or

    copy "c:\application.exe" "c:\documents and settings\%alluser%\desktop\shortcut to application.exe"

    New syntax for Vista

    copy "c:\application.exe" "c:\Users\%username%\Desktop\shortcut to application.exe"

    or


    copy "c:\application.exe" "c:\Users\%allusers%\Desktop\shortcut to application.exe"


    hopefully will help you...
  7. copy "c:\application.exe" "c:\documents and settings\%username%\desktop\shortcut to application.exe"...........

    All four of your examples copy the entire "application.exe" file rather than creating a shortcut to the original file.
  8. "Curious as to why you want to do this when drag and drop in Windows
    works so easily to create shortcuts?"

    "Drag and drop" is not a batch function. There are many reasons for batch file operations in a computing environment, and the need to create a shortcut from a batch file is quite legitimate.
  9. Why are you replying to a 5-year old thread? I doubt the OP is still there.
  10. graywolf said:
    Why are you replying to a 5-year old thread? I doubt the OP is still there.



    The message to which I replied is dated "03-15-2010 at 04:40:28 AM". I ran across it in a search for information on this subject yesterday. But even if the thread were 100 years old, it is still there, and misinformation should be corrected.
  11. The thread was resurrected on 3/15, but the original post is from 7/05. But you do have a point. Don't know how the mods feel about these things.

  12. OK, it is old but in my case I want to add shorcuts to Command Lines (ping, convert, label, etc.) from Start > Programs > Command Lines.

    So when one clicks on one of them it opens a DOS windows (in XP) and waits for the input

    How can I do this?
  13. didadocom said:
    OK, it is old but in my case I want to add shorcuts to Command Lines (ping, convert, label, etc.) from Start > Programs > Command Lines.

    So when one clicks on one of them it opens a DOS windows (in XP) and waits for the input

    How can I do this?


    I'm not sure what you are trying to do. You can open an MS-DOS window in XP by clicking "Start > Run", type "command.com", and click "OK". Then you can enter any MS-DOS command that is available under Windoze XP. To close the window, type exit, or close the same way as any window.

    Alternately, you can open a much more powerful "command prompt" by clicking "Start > Run", type "cmd", and click "OK". Then you can enter MS-DOS commands and numerous Windoze extensions. Close the window as above.

    If you want to create a short-cut (to one of the above) to place on your desktop (or elsewhere), click "Start > Search" and enter "command.com" and/or "cmd.exe". Then right click on the specified file found in the "windows\system32" folder, click "create shortcut", and click "Yes" when asked if you wish to place it on your desktop. You can then move it to another location if you so desire.

    If you wish to create a shortcut to execute a particular MS-DOS command (or series of commands), you need to create a batch file (text file with the suffix .bat) containing the command, and then create a short-cut to the batch file.
  14. Quote:
    If you wish to create a shortcut to execute a particular MS-DOS command (or series of commands), you need to create a batch file (text file with the suffix .bat) containing the command, and then create a short-cut to the batch file.


    This is what I want to do.
  15. I finished making the batch files for adding shortcuts to the programs that Windows XP (Home or Professional) doesn’t install by default.

    The batch file that I made “Windows XP Hidden Applications“ install all the shortcuts to the applications that Windows XP doesn’t call and that are "hidden" inside directories and folders. There are 62 applications that doesn’t appear in any way unless one knows the name and extension or the keyboard shortcut to call it.

    Excluded are those that are installed but not seen as System Administrative Tools that resides in Control Panel, and if you want to see it in Accessories, you must go to Control Panel > Taskbar and Start Menu > Start Menu > Customize > Advanced > System Administrative Tools and tick Display on the All Programs menu.

    In order that all applications are seen one must install Windows XP with Service Pack 3 complete. After completing the standard installation go to Control Panel > Add or Remove Programs > Add/Remove Windows Components and tick all the options. If you do not label some of them, the associated shortcuts will not work. But this is a option that you decide and depends of your actual requirements.

    I also made another batch installer “Windows XP Command Line”, with 210 command lines. I included only those that respond to the command line. There are others, but the command line must be applied directly in order to function.

    This is a job that can be improved and if anything is missing or there are errors I will appreciate your suggestion and will correct it. There is a ReadMe.txt file with the instructions.

    You can find the batch files here: http://lounge.windowssecrets.com/index.php?showtopic=776543
  16. View the following link, all your questions should answred:

    Helewix.com - CreateFolders-and-Links

    Regards,
    Hendrik Wiese
  17. This topic has been closed by Mousemonkey
Ask a new question

Read More

Desktops Command Line Windows XP