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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Copying a shortcut to a new destination, Using VBS

Status
Not open for further replies.

KiaKia

Programmer
Mar 30, 2008
59
US
Hi,
I have a shortcut alreay created with modifies propertiesto address a MS Access application.
What I need to do is copying this shortcut to a new destination like Desktop, using a VBScript.
PLease let me know your comments.

THanks,
Kia

 
how about this:
Code:
 Set objFSO = CreateObject("Scripting.FileSystemObject")             
objfso.CopyFile "c:\source_file", "c:\target_file"
 
You need to use either of the Scripting.FileSystemObject methods Copy() or CopyFile(). Copy() can copy both files and folders, but only one at a time while CopyFile() can only copy files but can move multiple files with one operation. Here's some quick and dirty code that you'll need to change for your environment.

Code:
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set MyFile = objFSO.GetFile([YourFileName])
MyFile.Copy ([YourFileTarget])
 
Ha, and now you have examples of two different options. TMTOWTDI.
 
Hi,
I already tried both methods, they work to copy a file but not a shortcut. Even if I try to copy a file without mentioning its extention it is not working.
Should I add any extention to my shortcut name?

Thanks,
Kia
 
Shortcuts usually have the extension of .lnk.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top