Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need batch file to move shortcut from CD to Desktop 1

Status
Not open for further replies.

CactysJack

Programmer
Nov 5, 2002
45
US
I have a CD I distribute to users. I have a .BAT file (old fashioned perhaps) to make a folder on C:\ and copy *.* files to it from the CD.

One last problem I have is another command line to send a shortcut from the CD to the desktop. This might be easier if MS didn't have user desktops but going to the All Users desktop probably would work OK.

However, I don't know how to treat the shortcut as a file or what it's name is.

TIA,

John
 
The shortcut has a .lnk extension and is is in the dir the shortcut is in.
Example: if you look at a shortcut named Hello on the desktop, you will find a small file in
C:\Document and Settings\username\Desktop
Open a command prompt there, do a dir and you will see the file Hello.lnk.
That's the one you would need to copy then in that batch file.
Tip, if it is a shortcut which is to be used by all users, move that file to C:\Document and Settings\All users\Desktop. Then you only need 1 file for all. The solution is out there. [morning]
 
Thanks for the super quick help.

It sounds easy but a problem. When I look in C:\Document and Settings\username\Desktop the files do not have extensions. Even looking with "details". What am I doing wrong.

John
 
I got it! On inspiration I went to the DOS prompt and lo and behold the lnk extension appeared. I think I can handle it now. Windows wouldn't tell me anything more than it was a "shortcut".

Thanks for the lead.

John
 
If you want file extensions displayed. Uncheck "Hide Extensions For Known File Types" via Folder Options/ View.
 
Linney - Thanks for the tip but the block is not checked. Maybe XP is not so easily fooled.

Marcs41 - Trouble here too. The batch file containing copy *.lnk C:\Documents and Settings\All Users\Desktop didn't work due to "improper" syntax warning in DOS mode. I did send to D:\temp as an experiment and that worked. Maybe "DOS" doesn't like long names or names with spaces. This may be a dumb question, but what is the Windows equivalent of a DOS batch file?

John
 
Is the answer to my last question SCRIPT? Something else to learn? Or is there a workaround?

John
 
As I stated in my first anwer, you need to go into a command prompt to see the extension, unhiding it doe snot work hers ass you noticed, that's why I added that.
But, ok, you found out yourself.
Your other mistake is in the batchfile, you will need to respect the 8.3 format.
C:\Documents and Settings\All users\ becomes
C:\Docume~1\Alluse~1 etc.
To replace a long file name, just take the first 6 chars, skip the spaces and add ~1. If there is more then 1, you need ~1 and ~2 etc.
To see for yourself, click start - run - command (NOT CMD).
type a dir and see.
Play a bit with the CD command and you will find out how it works.


The solution is out there. [morning]
 
Marcs41,

You are right, I didn't read the fine print. Missed that crucial step. Anyway we found it.

And thanks for the naming tips in your last post. I am grateful for the time you spent helping.

Just before your last post a friend of mine emailed me what turns out to be a definitive solution. He uses double quotes like:

copy *.lnk "C:\Documents and Settings\All Users\Desktop"

(my exact command on a CD)

or another example: copy "so and so.ext" "C:\a directory"

Works like a champ!

This would make a great FAQ, I could find nothing about it in a few hours of searching.

I think that solves all my problems.

Thanks again,

John
 
You're welcome.
The double quote solution also works indeed, but not in pure DOS, so the 8.3 is more generic, be it also more annoying ;-)

Have fun The solution is out there. [morning]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top