Link to home
Start Free TrialLog in
Avatar of SuperSnooper
SuperSnooper

asked on

Batch File command to Copy a Shortcut from a CD to the Desktop

I have a batch file on a CD that copies an Access Database (type mde) from the CD to a folder on the hard drive. The Batch then copies a shotrcut from the CD to the desktop. The command that I am using is as follows:

Copy "Shortcut to Work_Order_DataBase.mde.lnk" "C:\Documents and Settings\All Users\Desktop\*.*"

I can click on the CD Shortcut and it will open the database in the C drive folder, but the command will not copy the shortcut to the desktop.


Avatar of Lee W, MVP
Lee W, MVP
Flag of United States of America image

Check your permissions on the All Users profile.  Also, when copying files from a CD, they have a tendoncy to be copied as READ ONLY - they way the CD makes them.

Try adding a line like this before the copy:

IF exist "%allusersprofile%\Desktop\Shortcut to Work_Order_DataBase.mde.lnk" attrib -r "%allusersprofile%\Desktop\Shortcut to Work_Order_DataBase.mde.lnk"

Then modify your copy line to read:

Copy "Shortcut to Work_Order_DataBase.mde.lnk" "%allusersprofile%\Desktop\*.*" /y
Avatar of A Syscokid
A Syscokid

Actually, try Copy "Work_Order_DataBase.mde.lnk" "%allusersprofile%\Desktop\*.*" /y

"Shortcut to" is not part of the DOS file name.
Avatar of SuperSnooper

ASKER

Guys...Bad News!

Neither of the comments worked. I copied and pasted so the coding is as submitted. The coding isn't finding the Shortcuts on the CD. The error code says "The system cannot find the file specified".

David
Are you sure the shortcut is ON the CD?

If you do a "dir" on the CD, what are the files returned?
The Shortcuts are on the CD.  I tested the shortcuts out to make sure that they would open the databases on the hard drive...They did.

In the past, I referenced the CD (D:\.......) and the files would copy.  After thinking about it, I realized that all computers don't have "D" as their CD drive. So I am trying to eleminate that problem.

PS: I also got the same error message for the "If" statement.

David
Please post the results of the DIR - I'm sure we can come up with a solution if we're not blind trying to..
Leew,

Here is the coding:

Copy "Work_Order_DataBase.mde" "C:\UMDR\DataBase\*.*"
Copy "Map_DataBase.mde" "C:\UMDR\DataBase\*.*"
Copy "TEST_DATA_Work_Order_DataBase.mde" "C:\UMDR\DataBase\*.*"
Copy "TEST_Map_DataBase.mde" "C:\UMDR\DataBase\*.*"

Copy "Work_Order_DataBase.mde.lnk" "%allusersprofile%\Desktop\*.*" /y
Copy "TEST_DATA_Work_Order_DataBase.mde.lnk" "%allusersprofile%\Desktop\*.*" /y

IF exist "%allusersprofile%\Desktop\Work_Order_DataBase.mde.lnk" attrib -r "%allusersprofile%\Desktop\Work_Order_DataBase.mde.lnk"
Copy "Work_Order_DataBase.mde.lnk" "%allusersprofile%\Desktop\*.*" /y
rem Copy "Shortcut to Work_Order_DataBase.mde.lnk" "%allusersprofile%\Desktop\*.*" /y

IF exist "%allusersprofile%\Desktop\TEST_DATA_Work_Order_DataBase.mde.lnk" attrib -r "%allusersprofile%\Desktop\TEST_DATA_Work_Order_DataBase.mde.lnk"
Copy "TEST_DATA_Work_Order_DataBase.mde.lnk" "%allusersprofile%\Desktop\*.*" /y

rem Copy "Shortcut to TEST_DATA_Work_Order_DataBase.mde.lnk" "%allusersprofile%\Desktop\*.*" /y

As you cansee there isfour copiesbefore the shortcut copies.  The first four copied the shortcuts and the"ifs" erroredout.

I can send you a screen print of the batch results if youwish. I willrequire ane-mailaddress to accomplish that. The results are type ".jpg".

Thanks
David
Hey.

Try using the COPY Command with the /V switch
Here2Help,
Can you post where the /V switch should be.

David
ASKER CERTIFIED SOLUTION
Avatar of Here2Help
Here2Help
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Here2Help,

I found another error.  The ".mde" was not a part of the shortcut name. It was just the extention  for the shortcut target. With this change, I can copy the shortcut from the CD to another folder.

Now...there is still one error.  The "%allusersprofile%\Desktop\....." is not the correct syntax. Any ideas?

David  
Here2Help,

Thanks Guy. I finally realized that the "%allusersprofile%" had not been defined.  Am I not a dummy! Anyway, it works like a charm.

David