Tom's Hardware > Forum > Windows XP > Windows XP General Discussion > Creating desktop shortcuts from the command line?

Creating desktop shortcuts from the command line?

Forum Windows XP : Windows XP General Discussion - Creating desktop shortcuts from the command line?

Tom's Hardware: Over 1.4 million members in 6 different countries available to answer all your high-tech questions. Sign up now! Its free!
Word :    Username :           
 

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

Sponsored Links
Register or log in to remove.

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

Please post all follow-ups to the newsgroup only.

Reply to Anonymous

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

Reply to Anonymous

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/m [...] urce&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/product [...] efault.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/s [...] fault.mspx

Reply to Anonymous

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

Reply to Anonymous

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/m [...] urce&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/product [...] efault.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/s [...] fault.mspx
>

Reply to Anonymous
Tom's Hardware > Forum > Windows XP > Windows XP General Discussion > Creating desktop shortcuts from the command line?
Go to:

There are 1216 identified and unidentified users. To see the list of identified users, Click here.

Please mind

You are about to answer a thread that has been inactive for more than 6 months.
If you still wish to proceed, please ensure that your posting is original and does not duplicate or overlap any prior responses to this thread.

Add a reply Cancel
Sponsored links
  • Ask the community now
  • Publish
Ad
They won a badge
Join us in greeting them