Link to home
Start Free TrialLog in
Avatar of Michael Vasilevsky
Michael VasilevskyFlag for United States of America

asked on

Copy Shortcut with Batch File

I'm trying to write a batch file that will move the front-end of my db to a user's local machine and place a shortcut on the desktop.  I'm able to move the front-end okay but am having trouble creating a shortcut (which specifies .mdw). I'm unable to copy a shortcut file.  The code:

copy "\\ServerName\FolderName\DataBaseName.lnk" "C:\Documents And Settings\%username%\desktop\ DataBaseName.lnk"

gives me the error: "The system cannot find the file specified."

I am able to copy other files to/from the specified folders without problem, so it has something to do with the shortcut file type.

Is there a way to create a shortcut with MS DOS commands?
Any help would be appreciated.
Thanks,

mv
Avatar of shanesuebsahakarn
shanesuebsahakarn
Flag of United Kingdom of Great Britain and Northern Ireland image

You appear to have a rogue space just before the DataBaseName.lnk in the second part of the copy statement. Could that be the problem?
Avatar of Rey Obrero (Capricorn1)
you need to place a copy of the .lnk at the specified folder
did you create a shortcut to your .mde?  this is how your shortcut Target should look like.

"C:\Program Files\Microsoft Office\Office10\MSACCESS.EXE" "C:\Documents and Settings\%username%\LocalFolder\Database.mde"
Avatar of Michael Vasilevsky

ASKER

capricorn1: I'm not using an .mde, just .mdb with user-level security, therefore my shortcut path needs to look like:

"C:\Program Files\Microsoft Office\Office\MSACCESS.EXE"  "C:\localfolder\DB_fe.mdb" /wrkgrp "\\Server\folder\db.MDW"

but my real problem is that I can't get MS DOS to copy any shortcut file with the syntax above.

Interestingly when I create the shortcut it does not have a .lnk extension.  If I add .lnk or any extension it's still a shortcut file and still won't copy.  (I do see file extensions for all other files in the same folder)

help!
Out of interest, if you manually execute that command from a DOS window, does it work?
shanesuebsahakarn: no, same error : (

Are you able to move a shortcut with DOS okay?
I am yes, on WinXP. I haven't tested with a UNC path though. It does require the lnk extension though.
okay, I have a .mdb file in C:\test\test.mdb.  I right-click, select Create Shortcut, and it creates a shortcut called "test".  Now I change the file name to "test.lnk"?  Either way:

copy "C:\test\test.lnk" "C:\test.lnk"

fails with the message "The System cannot find the file specified."  

copy "C:\test\test.mdb" "C:\test.mdb"

works fine.
 
This is on Win 2000 or XP.
ASKER CERTIFIED SOLUTION
Avatar of shanesuebsahakarn
shanesuebsahakarn
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
Aha, that worked.  
Thanks shanesuebsahakarn.