Jump to content

Copy shortcut to desktop in a batch file


Recommended Posts

Guest Diane Walker
Posted

I use Installshield software to setup the executable file to install the

software. In that executable file, I setup a batch file to copy a

shortcut to the desktop. The executable file ran successfully. However,

the shortcut was not copied to the desktop. I got the error message "File

not found" for the shortcut command. Do you have any suggestions? Thanks.

  • Replies 15
  • Created
  • Last Reply
Guest AlmostBob
Posted

Re: Copy shortcut to desktop in a batch file

 

batch files cant contain spaces in file names, so

copy \program files\thisfile.ext \anydestination

fails

copy "\program files\thisfile.ext" "\anydestination in quotes around spaces"

proceeds

 

the copy may fail if you specify a desktop foldername, that does not exist

this pc has none of

C:\documents and settings\all users\desktop

C:\documents and settings\all users

C:\documents and settings

C:\documents and settings\user\desktop

C:\documents and settings\user

 

but %Homedrive%%Homepath%\desktop

works as does

%Homedrive%%allusersprofile%\desktop

windowsXP is on a virtual drive P: running as a toy in the background

 

batch files are unfriendly and expect you to code for all possibilities,

 

--

Adaware http://www.lavasoft.de

spybot http://www.safer-networking.org

AVG free antivirus http://www.grisoft.com

Etrust/Vet/CA.online Antivirus scan

http://www3.ca.com/securityadvisor/virusinfo/scan.aspx

Panda online AntiVirus scan http://www.pandasoftware.com/ActiveScan/

Catalog of removal tools (1)

http://www.pandasoftware.com/download/utilities/

Catalog of removal tools (2)

http://www3.ca.com/securityadvisor/newsinfo/collateral.aspx?CID=40387

Blocking Unwanted Parasites with a Hosts file

http://mvps.org/winhelp2002/hosts.htm

links provided as a courtesy, read all instructions on the pages before use

 

Grateful thanks to the authors and webmasters

_

 

"Diane Walker" <ett9300@yahoo.com> wrote in message

news:OLwC$w06IHA.1196@TK2MSFTNGP05.phx.gbl...

>I use Installshield software to setup the executable file to install the

>software. In that executable file, I setup a batch file to copy a

>shortcut to the desktop. The executable file ran successfully. However,

>the shortcut was not copied to the desktop. I got the error message "File

>not found" for the shortcut command. Do you have any suggestions? Thanks.

>

Guest Pegasus \(MVP\)
Posted

Re: Copy shortcut to desktop in a batch file

 

Your reply is basically correct but a little confusing - see below.

 

"AlmostBob" <anonymous1@microsoft.com> wrote in message

news:udbcBE16IHA.4596@TK2MSFTNGP03.phx.gbl...

> batch files cant contain spaces in file names, so

*** Yes, they can.

> copy \program files\thisfile.ext \anydestination fails

> copy "\program files\thisfile.ext" "\anydestination in quotes around

> spaces"

> proceeds

*** This is because folder/file names that have embedded spaces

*** must be surrounded by double quotes. This is a requirement

*** of console commands and has nothing to do with batch files.

> the copy may fail if you specify a desktop foldername, that does not exist

> this pc has none of

> C:\documents and settings\all users\desktop

> C:\documents and settings\all users

> C:\documents and settings

> C:\documents and settings\user\desktop

> C:\documents and settings\user

*** All of the above must be surrounded by double quotes.

> but %Homedrive%%Homepath%\desktop

> works as does

> %Homedrive%%allusersprofile%\desktop

*** No, they do not, because %HomePath% and %AllUsersProfile%

*** have embedded spaces. They must be surrounded by double quotes.

> windowsXP is on a virtual drive P: running as a toy in the background

*** Meaning?

> batch files are unfriendly and expect you to code for all possibilities,

*** Batch files, same as console commands, require precise coding.

*** They have no safety net, as opposed to GUIs.

> "Diane Walker" <ett9300@yahoo.com> wrote in message

> news:OLwC$w06IHA.1196@TK2MSFTNGP05.phx.gbl...

>>I use Installshield software to setup the executable file to install the

>>software. In that executable file, I setup a batch file to copy a

>>shortcut to the desktop. The executable file ran successfully. However,

>>the shortcut was not copied to the desktop. I got the error message "File

>>not found" for the shortcut command. Do you have any suggestions? Thanks.

>>

>

>

Guest Pegasus \(MVP\)
Posted

Re: Copy shortcut to desktop in a batch file

 

 

"Diane Walker" <ett9300@yahoo.com> wrote in message

news:OLwC$w06IHA.1196@TK2MSFTNGP05.phx.gbl...

>I use Installshield software to setup the executable file to install the

>software. In that executable file, I setup a batch file to copy a

>shortcut to the desktop. The executable file ran successfully. However,

>the shortcut was not copied to the desktop. I got the error message "File

>not found" for the shortcut command. Do you have any suggestions? Thanks.

 

Let's have a look at your batch file!

Guest Diane Walker
Posted

Re: Copy shortcut to desktop in a batch file

 

Thank you very much all for your prompt response.

 

The batch file is

copy XXX.lnk "%allusersprofile\desktop"

 

The error message said "file not found". I interpret that the batch file

cannot find "XXX.lnk" file even though the shortcut "XXX.lnk" does exist.

Please let me know if you need additional information. Thanks.

 

"Pegasus (MVP)" <I.can@fly.com.oz> wrote in message

news:%23%23XQke16IHA.1460@TK2MSFTNGP06.phx.gbl...

>

> "Diane Walker" <ett9300@yahoo.com> wrote in message

> news:OLwC$w06IHA.1196@TK2MSFTNGP05.phx.gbl...

>>I use Installshield software to setup the executable file to install the

>>software. In that executable file, I setup a batch file to copy a

>>shortcut to the desktop. The executable file ran successfully. However,

>>the shortcut was not copied to the desktop. I got the error message "File

>>not found" for the shortcut command. Do you have any suggestions? Thanks.

>

> Let's have a look at your batch file!

>

Guest Bill Sharpe
Posted

Re: Copy shortcut to desktop in a batch file

 

Diane Walker wrote:

> Thank you very much all for your prompt response.

>

> The batch file is

> copy XXX.lnk "%allusersprofile\desktop"

>

Add the full path to XXX.lnk,

e.g. copy "C:\My Install Directory\XXX.lnk"

 

Bill

Guest Pegasus \(MVP\)
Posted

Re: Copy shortcut to desktop in a batch file

 

Instead of writing

 

copy XXX.lnk "%allusersprofile\desktop", try this:

copy /y XXX.lnk "%allusersprofile%\desktop"

 

You'll notice the missing "%". The "/y" switch will ensure

that there will be no prompt in case the file already exists.

 

Furthermore, to make your batch file robust, add the full path

to your source file, e.g. like so:

 

xcopy /y /d "U:\Some Folder\XXX.lnk" "%allusersprofile%\desktop"

 

Using xcopy.exe with the /d switch will prevent mindless

copying of the same file each time the use command is

invoked.

 

 

 

"Diane Walker" <ett9300@yahoo.com> wrote in message

news:%23djR3r16IHA.4292@TK2MSFTNGP02.phx.gbl...

> Thank you very much all for your prompt response.

>

> The batch file is

> copy XXX.lnk "%allusersprofile\desktop"

>

> The error message said "file not found". I interpret that the batch file

> cannot find "XXX.lnk" file even though the shortcut "XXX.lnk" does exist.

> Please let me know if you need additional information. Thanks.

>

> "Pegasus (MVP)" <I.can@fly.com.oz> wrote in message

> news:%23%23XQke16IHA.1460@TK2MSFTNGP06.phx.gbl...

>>

>> "Diane Walker" <ett9300@yahoo.com> wrote in message

>> news:OLwC$w06IHA.1196@TK2MSFTNGP05.phx.gbl...

>>>I use Installshield software to setup the executable file to install the

>>>software. In that executable file, I setup a batch file to copy a

>>>shortcut to the desktop. The executable file ran successfully. However,

>>>the shortcut was not copied to the desktop. I got the error message

>>>"File not found" for the shortcut command. Do you have any suggestions?

>>>Thanks.

>>

>> Let's have a look at your batch file!

>>

>

>

Guest Diane Walker
Posted

Re: Copy shortcut to desktop in a batch file

 

Thank you very much for your prompt response and suggestions. I still got

the same error message.

 

"Pegasus (MVP)" <I.can@fly.com.oz> wrote in message

news:OBy1RF26IHA.1080@TK2MSFTNGP06.phx.gbl...

> Instead of writing

>

> copy XXX.lnk "%allusersprofile\desktop", try this:

> copy /y XXX.lnk "%allusersprofile%\desktop"

>

> You'll notice the missing "%". The "/y" switch will ensure

> that there will be no prompt in case the file already exists.

>

> Furthermore, to make your batch file robust, add the full path

> to your source file, e.g. like so:

>

> xcopy /y /d "U:\Some Folder\XXX.lnk" "%allusersprofile%\desktop"

>

> Using xcopy.exe with the /d switch will prevent mindless

> copying of the same file each time the use command is

> invoked.

>

>

>

> "Diane Walker" <ett9300@yahoo.com> wrote in message

> news:%23djR3r16IHA.4292@TK2MSFTNGP02.phx.gbl...

>> Thank you very much all for your prompt response.

>>

>> The batch file is

>> copy XXX.lnk "%allusersprofile\desktop"

>>

>> The error message said "file not found". I interpret that the batch file

>> cannot find "XXX.lnk" file even though the shortcut "XXX.lnk" does exist.

>> Please let me know if you need additional information. Thanks.

>>

>> "Pegasus (MVP)" <I.can@fly.com.oz> wrote in message

>> news:%23%23XQke16IHA.1460@TK2MSFTNGP06.phx.gbl...

>>>

>>> "Diane Walker" <ett9300@yahoo.com> wrote in message

>>> news:OLwC$w06IHA.1196@TK2MSFTNGP05.phx.gbl...

>>>>I use Installshield software to setup the executable file to install the

>>>>software. In that executable file, I setup a batch file to copy a

>>>>shortcut to the desktop. The executable file ran successfully.

>>>>However, the shortcut was not copied to the desktop. I got the error

>>>>message "File not found" for the shortcut command. Do you have any

>>>>suggestions? Thanks.

>>>

>>> Let's have a look at your batch file!

>>>

>>

>>

>

>

Guest Terry R.
Posted

Re: Copy shortcut to desktop in a batch file

 

The date and time was 7/21/2008 5:00 PM, and on a whim, Diane Walker

pounded out on the keyboard:

> Thank you very much for your prompt response and suggestions. I still got

> the same error message.

>

> "Pegasus (MVP)" <I.can@fly.com.oz> wrote in message

> news:OBy1RF26IHA.1080@TK2MSFTNGP06.phx.gbl...

>> Instead of writing

>>

>> copy XXX.lnk "%allusersprofile\desktop", try this:

>> copy /y XXX.lnk "%allusersprofile%\desktop"

>>

>> You'll notice the missing "%". The "/y" switch will ensure

>> that there will be no prompt in case the file already exists.

>>

>> Furthermore, to make your batch file robust, add the full path

>> to your source file, e.g. like so:

>>

>> xcopy /y /d "U:\Some Folder\XXX.lnk" "%allusersprofile%\desktop"

>>

>> Using xcopy.exe with the /d switch will prevent mindless

>> copying of the same file each time the use command is

>> invoked.

>>

>>

>>

>> "Diane Walker" <ett9300@yahoo.com> wrote in message

>> news:%23djR3r16IHA.4292@TK2MSFTNGP02.phx.gbl...

>>> Thank you very much all for your prompt response.

>>>

>>> The batch file is

>>> copy XXX.lnk "%allusersprofile\desktop"

>>>

>>> The error message said "file not found". I interpret that the batch file

>>> cannot find "XXX.lnk" file even though the shortcut "XXX.lnk" does exist.

>>> Please let me know if you need additional information. Thanks.

>>>

>>> "Pegasus (MVP)" <I.can@fly.com.oz> wrote in message

>>> news:%23%23XQke16IHA.1460@TK2MSFTNGP06.phx.gbl...

>>>> "Diane Walker" <ett9300@yahoo.com> wrote in message

>>>> news:OLwC$w06IHA.1196@TK2MSFTNGP05.phx.gbl...

>>>>> I use Installshield software to setup the executable file to install the

>>>>> software. In that executable file, I setup a batch file to copy a

>>>>> shortcut to the desktop. The executable file ran successfully.

>>>>> However, the shortcut was not copied to the desktop. I got the error

>>>>> message "File not found" for the shortcut command. Do you have any

>>>>> suggestions? Thanks.

>>>> Let's have a look at your batch file!

>>>>

>>>

>>

>

>

 

Hi Diane,

 

Combining the suggestions of Bill and Pegasus should resolve your issue.

You need to include the full path of XXX.lnk as I doubt the batch file

is in the same folder as the LNK file.

 

--

Terry R.

 

***Reply Note***

Anti-spam measures are included in my email address.

Delete NOSPAM from the email address after clicking Reply.

Guest Terry R.
Posted

Re: Copy shortcut to desktop in a batch file

 

The date and time was 7/21/2008 11:40 AM, and on a whim, Pegasus (MVP)

pounded out on the keyboard:

> Instead of writing

>

> copy XXX.lnk "%allusersprofile\desktop", try this:

> copy /y XXX.lnk "%allusersprofile%\desktop"

>

> You'll notice the missing "%". The "/y" switch will ensure

> that there will be no prompt in case the file already exists.

>

> Furthermore, to make your batch file robust, add the full path

> to your source file, e.g. like so:

>

> xcopy /y /d "U:\Some Folder\XXX.lnk" "%allusersprofile%\desktop"

>

> Using xcopy.exe with the /d switch will prevent mindless

> copying of the same file each time the use command is

> invoked.

>

>

>

> "Diane Walker" <ett9300@yahoo.com> wrote in message

> news:%23djR3r16IHA.4292@TK2MSFTNGP02.phx.gbl...

>> Thank you very much all for your prompt response.

>>

>> The batch file is

>> copy XXX.lnk "%allusersprofile\desktop"

>>

>> The error message said "file not found". I interpret that the batch file

>> cannot find "XXX.lnk" file even though the shortcut "XXX.lnk" does exist.

>> Please let me know if you need additional information. Thanks.

>>

>> "Pegasus (MVP)" <I.can@fly.com.oz> wrote in message

>> news:%23%23XQke16IHA.1460@TK2MSFTNGP06.phx.gbl...

>>> "Diane Walker" <ett9300@yahoo.com> wrote in message

>>> news:OLwC$w06IHA.1196@TK2MSFTNGP05.phx.gbl...

>>>> I use Installshield software to setup the executable file to install the

>>>> software. In that executable file, I setup a batch file to copy a

>>>> shortcut to the desktop. The executable file ran successfully. However,

>>>> the shortcut was not copied to the desktop. I got the error message

>>>> "File not found" for the shortcut command. Do you have any suggestions?

>>>> Thanks.

>>> Let's have a look at your batch file!

>>>

>>

>

>

 

Sorry Pegasus, I didn't see that you also suggested adding the path to

the source when I replied to Diane.

 

--

Terry R.

 

***Reply Note***

Anti-spam measures are included in my email address.

Delete NOSPAM from the email address after clicking Reply.

Guest Pegasus \(MVP\)
Posted

Re: Copy shortcut to desktop in a batch file

 

 

"Diane Walker" <ett9300@yahoo.com> wrote in message

news:ebArj346IHA.5440@TK2MSFTNGP02.phx.gbl...

> Thank you very much for your prompt response and suggestions. I still got

> the same error message.

>

 

Same answer as before: Let's see your current command.

Remember - we can't see your machine! You should also

report how you're running your batch file:

- By double-clicking a shortcut;

- By running it from a Command Prompt;

- By invoking it via the Task Scheduler;

- Other.

Guest Diane Walker
Posted

Re: Copy shortcut to desktop in a batch file

 

Sorry for not giving me enough information. Thanks very much for your

prompt response. The batch file is

copy /Y "%temp%\XXX.lnk" "%ALLUSERSPROFILE%\desktop"

 

Thanks.

 

"Pegasus (MVP)" <I.can@fly.com.oz> wrote in message

news:eHT58J86IHA.1196@TK2MSFTNGP05.phx.gbl...

>

> "Diane Walker" <ett9300@yahoo.com> wrote in message

> news:ebArj346IHA.5440@TK2MSFTNGP02.phx.gbl...

>> Thank you very much for your prompt response and suggestions. I still

>> got the same error message.

>>

>

> Same answer as before: Let's see your current command.

> Remember - we can't see your machine! You should also

> report how you're running your batch file:

> - By double-clicking a shortcut;

> - By running it from a Command Prompt;

> - By invoking it via the Task Scheduler;

> - Other.

>

Guest Pegasus \(MVP\)
Posted

Re: Copy shortcut to desktop in a batch file

 

The command works perfectly well on my machine - provided that

the file "%temp%\xxx.lnk" exists.

 

I note that you did not answer my question about hour method

for invoking this command. Furthermore, if you embed it in a

batch file then perhaps the error is generated by a different

command. You should post the whole batch file, not just a fragment.

 

 

"Diane Walker" <ett9300@yahoo.com> wrote in message

news:e4SrLEB7IHA.1192@TK2MSFTNGP05.phx.gbl...

> Sorry for not giving me enough information. Thanks very much for your

> prompt response. The batch file is

> copy /Y "%temp%\XXX.lnk" "%ALLUSERSPROFILE%\desktop"

>

> Thanks.

>

> "Pegasus (MVP)" <I.can@fly.com.oz> wrote in message

> news:eHT58J86IHA.1196@TK2MSFTNGP05.phx.gbl...

>>

>> "Diane Walker" <ett9300@yahoo.com> wrote in message

>> news:ebArj346IHA.5440@TK2MSFTNGP02.phx.gbl...

>>> Thank you very much for your prompt response and suggestions. I still

>>> got the same error message.

>>>

>>

>> Same answer as before: Let's see your current command.

>> Remember - we can't see your machine! You should also

>> report how you're running your batch file:

>> - By double-clicking a shortcut;

>> - By running it from a Command Prompt;

>> - By invoking it via the Task Scheduler;

>> - Other.

>>

>

>

Guest Bill Sharpe
Posted

Re: Copy shortcut to desktop in a batch file

 

Diane Walker wrote:

> Sorry for not giving me enough information. Thanks very much for your

> prompt response. The batch file is

> copy /Y "%temp%\XXX.lnk" "%ALLUSERSPROFILE%\desktop"

>

> Thanks.

 

 

Are you sure that XXX.lnk exists in your %temp% directory?

You can run

dir %temp% XXX.lnk

from a command window to check.

I, of course, get "file not found" when I do so.

 

Bill

Guest Diane Walker
Posted

Re: Copy shortcut to desktop in a batch file

 

Thank you for your prompt response, again. Sorry for not answering your

question. I put the command in a batch file (install.bat). Then, I use the

Installshield software to make the batch file become an executable file

(install.exe). Then, I run file "install.exe". That is why I got the

error about shortcut link. Please let me know if you need additional

information or I miss anything.

 

Thanks.

 

"Pegasus (MVP)" <I.can@fly.com.oz> wrote in message

news:%2326miVB7IHA.4108@TK2MSFTNGP04.phx.gbl...

> The command works perfectly well on my machine - provided that

> the file "%temp%\xxx.lnk" exists.

>

> I note that you did not answer my question about hour method

> for invoking this command. Furthermore, if you embed it in a

> batch file then perhaps the error is generated by a different

> command. You should post the whole batch file, not just a fragment.

>

>

> "Diane Walker" <ett9300@yahoo.com> wrote in message

> news:e4SrLEB7IHA.1192@TK2MSFTNGP05.phx.gbl...

>> Sorry for not giving me enough information. Thanks very much for your

>> prompt response. The batch file is

>> copy /Y "%temp%\XXX.lnk" "%ALLUSERSPROFILE%\desktop"

>>

>> Thanks.

>>

>> "Pegasus (MVP)" <I.can@fly.com.oz> wrote in message

>> news:eHT58J86IHA.1196@TK2MSFTNGP05.phx.gbl...

>>>

>>> "Diane Walker" <ett9300@yahoo.com> wrote in message

>>> news:ebArj346IHA.5440@TK2MSFTNGP02.phx.gbl...

>>>> Thank you very much for your prompt response and suggestions. I still

>>>> got the same error message.

>>>>

>>>

>>> Same answer as before: Let's see your current command.

>>> Remember - we can't see your machine! You should also

>>> report how you're running your batch file:

>>> - By double-clicking a shortcut;

>>> - By running it from a Command Prompt;

>>> - By invoking it via the Task Scheduler;

>>> - Other.

>>>

>>

>>

>

>

Guest Diane Walker
Posted

Re: Copy shortcut to desktop in a batch file

 

Thanks for the tip, Bill. I do not see XXX.lnk in the %temp% directory. I

will go back to my batch file and see why the shortcut link did not copy to

the %temp% directory. Thanks again.

 

"Bill Sharpe" <wfsnopam@adelphia.net> wrote in message

news:ek7WLkB7IHA.392@TK2MSFTNGP03.phx.gbl...

> Diane Walker wrote:

>> Sorry for not giving me enough information. Thanks very much for your

>> prompt response. The batch file is

>> copy /Y "%temp%\XXX.lnk" "%ALLUSERSPROFILE%\desktop"

>>

>> Thanks.

>

>

> Are you sure that XXX.lnk exists in your %temp% directory?

> You can run

> dir %temp% XXX.lnk

> from a command window to check.

> I, of course, get "file not found" when I do so.

>

> Bill


×
×
  • Create New...