Re: Copying a Link's Target File by tdan
tdan
Wed Jun 13 01:16:59 CDT 2007
Hey thanks a lot.
That would probably work well, but I am getting the following error:
Line: 12
Char: 1
Error: Permission denied
Code: 800A0046
Weird.
- I have administrator rights with Full Control over the .vbs file.
- None of the links, folders, and target files are Read Only and do
not contain special permissions.
What is wrong now?!!
On Jun 12, 11:25 am, urkec <u...@discussions.microsoft.com> wrote:
> "danf" wrote:
> > I want to:
> > 1. iterate through a folder of shortcuts
> > 2. Get the target path
> > 3.Copythe target file back to the folder of links.
>
> > Here is my attempt. Any suggestions?
>
> > Set oFSO = CreateObject("Scripting.FileSystemObject")
> > Set oFolderOfLinks = oFSO.GetFolder("C:\Documents and Settings\Dan
> > \Desktop\Links")
>
> > Set colFiles = oFolderOfLinks.Files
>
> > For Each oFile in colFiles
> > If strcomp(right(oFile.name,4),".lnk", vbTextCompare) = 0 Then
> > Set oLink = oFile.TargetPath
> > Set oLinkedFile = oFSO.GetFile(oLink)
> > oLink.CopyoFolderOfLinks
> > End If
> > Next
>
> strFolder = "C:\xy\"
>
> Set oFSO = CreateObject("Scripting.FileSystemObject")
> Set oFolderOfLinks = oFSO.GetFolder(strFolder)
> Set WshShell = CreateObject ("WScript.Shell")
>
> Set colFiles = oFolderOfLinks.Files
>
> For Each oFile in colFiles
> If oFSO.GetExtensionName (oFile.Name) = "lnk" Then
> Set oLink = WshShell.CreateShortcut(oFile.Path)
> oFSO.CopyFile oLink.TargetPath, strFolder, True
> End If
> Next
>
> --
> urkec