General discussion

Locked

desktop shortcuts via command line/batch

By peter.berger@genexsrvcs ·
All -- is there a way, just like using the mouse and right-clicking, to create a functional desktop shortcut to launch an application?

I've tried: copy c:\application.exe "c:\documents and settings\%username%\desktop\shortcut to application.lnk" and it doesn't work.
It does create an icon on the desktop, but clicking it does nothing and right-clicking it says its an invalid shortcut.
I've tried copy/xcopy w/ various switches.

Any 411/help would be great...thanks...

This conversation is currently closed to new comments.

5 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

by haileyan In reply to desktop shortcuts via com ...

All you are doing in your example is renaming an executable. You are on the right track. Create a shortcut to the application copy the shortcut somewhere that it is accessible on the network.

So it will be:
copy \\server\share\application.lnk "c:\documents and settings\%username%\desktop\*.*"

If this is an appliction that everyone on the computer will use:

copy \\server\share\application.lnk "c:\documents and settings\All Users\desktop\*.*"

Collapse -

by peter.berger@genexsrvcs In reply to

Thanks, but the wscripting below was the solution needed. :)

Collapse -

by ewgny In reply to desktop shortcuts via com ...

Try using a simple vbscript
change the special folders entry to
where you want the shortcut
http://tinyurl.com/6odth


set WshShell = WScript.CreateObject("WScript.Shell")
strDesktop = WshShell.SpecialFolders("Desktop")
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

Collapse -

by peter.berger@genexsrvcs In reply to

I used the Wscript.exe syntax:
Shell.SpecialFolders("AllUsersDesktop")
and it worked great by putting the needed shortcut on the All Users Desktop.
Thanks for the tip!

Collapse -

This question was closed by the author

Back to Windows Forum
5 total posts (Page 1 of 1)  

Related Discussions

Related Forums