Sign in with
Sign up | Sign in
Your question
Closed

Creating desktop shortcuts from the command line?

Tags:
  • Desktops
  • Command Line
  • Windows XP
Last response: in Windows XP
Share
Anonymous
July 11, 2005 4:19:05 PM

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...

More about : creating desktop shortcuts command line

Anonymous
July 11, 2005 5:02:44 PM

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...
Anonymous
July 11, 2005 7:31:45 PM

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/w....
--
Tom Porterfield
MS-MVP Windows
http://support.telop.org

Please post all follow-ups to the newsgroup only.
Related resources
Anonymous
July 12, 2005 12:15:02 PM

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...
>
>
>
Anonymous
July 12, 2005 6:09:29 PM

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.scrip...

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/De...


--
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.m...
Anonymous
July 12, 2005 6:09:30 PM

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.scrip...
>
> 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/De...
>
>
> --
> 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.m...
>
March 15, 2010 7:40:28 AM

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...
April 23, 2010 10:12:40 AM

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.
April 23, 2010 10:21:11 AM

"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.
April 23, 2010 2:39:03 PM

Why are you replying to a 5-year old thread? I doubt the OP is still there.
April 23, 2010 8:24:47 PM

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.
April 23, 2010 8:29:00 PM

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.

July 21, 2010 7:29:15 PM

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?
July 21, 2010 8:03:22 PM

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.
July 22, 2010 3:41:38 AM

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.
July 30, 2010 6:08:40 PM

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=77...
September 22, 2010 5:10:04 PM

This topic has been closed by Mousemonkey
!