[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 447
  • Last Modified:

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
0
Michael Vasilevsky
Asked:
Michael Vasilevsky
  • 4
  • 4
  • 2
1 Solution
 
shanesuebsahakarnCommented:
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?
0
 
Rey Obrero (Capricorn1)Commented:
you need to place a copy of the .lnk at the specified folder
0
 
Rey Obrero (Capricorn1)Commented:
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"
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
Michael VasilevskySolutions ArchitectAuthor Commented:
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!
0
 
shanesuebsahakarnCommented:
Out of interest, if you manually execute that command from a DOS window, does it work?
0
 
Michael VasilevskySolutions ArchitectAuthor Commented:
shanesuebsahakarn: no, same error : (

Are you able to move a shortcut with DOS okay?
0
 
shanesuebsahakarnCommented:
I am yes, on WinXP. I haven't tested with a UNC path though. It does require the lnk extension though.
0
 
Michael VasilevskySolutions ArchitectAuthor Commented:
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.
0
 
shanesuebsahakarnCommented:
Don't change the filename to test.lnk. By default, it is already called test.lnk, you just can't see the lnk extension (Windows will hide this regardless of your Show Extension settings).
0
 
Michael VasilevskySolutions ArchitectAuthor Commented:
Aha, that worked.  
Thanks shanesuebsahakarn.
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

  • 4
  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now