Hi,
I'm new to scripting and could use some help please...

I need to get the target of all the shortcuts in users local profile
under the Recent folder (i.e. C:\Documents and Settings\<Username>
\Recent.

The goal is to see if any of their "recent files/folders" are
referencing URLs or using mapped drives.

I would like the script to:
1) get the list of shortcuts in the "Recent" folder for the logged in
user.
2) traverse the "target" property of each shortcut found.
3) log the targets to a text file.

I've written a script that can get the target property of a shortcut,
but that's as far as my scripting can take me... just starting out.

Thanks in advance!

Re: Get the "target" property of shortcuts in a directory by Ayush

Ayush
Wed Jul 25 18:37:21 CDT 2007

[John] wrote-:
> I would like the script to:
> 1) get the list of shortcuts in the "Recent" folder for the logged in user.
> 2) traverse the "target" property of each shortcut found.
> 3) log the targets to a text file.

logFile="C:\Recent Shortcut Targets.txt"
Set ws=CreateObject("WScript.Shell")
Set fs=CreateObject("Scripting.FileSystemObject")
Set recent=fs.GetFolder(ws.SpecialFolders("Recent"))
Set logFile=fs.OpenTextFile(logFile,2,true)
For each file in recent.files
path=file.path
if fs.GetExtensionName(path)="lnk" then
logFile.WriteLine ws.CreateShortcut(path).TargetPath
End if
next

Good Luck, Ayush.
--
Script Center : http://microsoft.com/technet/scriptcenter/default.mspx

Re: Get the "target" property of shortcuts in a directory by Ayush

Ayush
Wed Jul 25 18:42:32 CDT 2007

[Ayush] wrote-:
> [John] wrote-:
>> I would like the script to:
>> 1) get the list of shortcuts in the "Recent" folder for the logged in
>> user.
>> 2) traverse the "target" property of each shortcut found.
>> 3) log the targets to a text file.

> logFile="C:\Recent Shortcut Targets.txt"
> Set ws=CreateObject("WScript.Shell")
> Set fs=CreateObject("Scripting.FileSystemObject")
> Set recent=fs.GetFolder(ws.SpecialFolders("Recent"))
> Set logFile=fs.OpenTextFile(logFile,2,true)
> For each file in recent.files


> path=file.path
> if fs.GetExtensionName(path)="lnk" then

Change the above lines to :
path=file.path
ext=fs.GetExtensionName(path)
if ext="lnk" or ext="url" Then

> logFile.WriteLine ws.CreateShortcut(path).TargetPath
> End if
> next

> Good Luck, Ayush.

Good Luck, Ayush.
--
Script Center-Script Repository : http://snipurl.com/Script_Repository

Re: Get the "target" property of shortcuts in a directory by John

John
Thu Jul 26 09:59:05 CDT 2007

On Jul 25, 7:42 pm, Ayush <"ayushmaan.j[aatt]gmail.com"> wrote:
> [Ayush] wrote-:
>
> > [John] wrote-:
> >> I would like the script to:
> >> 1) get the list of shortcuts in the "Recent" folder for the logged in
> >> user.
> >> 2) traverse the "target" property of each shortcut found.
> >> 3) log the targets to a text file.
> > logFile="C:\Recent Shortcut Targets.txt"
> > Set ws=CreateObject("WScript.Shell")
> > Set fs=CreateObject("Scripting.FileSystemObject")
> > Set recent=fs.GetFolder(ws.SpecialFolders("Recent"))
> > Set logFile=fs.OpenTextFile(logFile,2,true)
> > For each file in recent.files
> > path=file.path
> > if fs.GetExtensionName(path)="lnk" then
>
> Change the above lines to :
> path=file.path
> ext=fs.GetExtensionName(path)
> if ext="lnk" or ext="url" Then
>
> > logFile.WriteLine ws.CreateShortcut(path).TargetPath
> > End if
> > next
> > Good Luck, Ayush.
>
> Good Luck, Ayush.
> --
> Script Center-Script Repository :http://snipurl.com/Script_Repository

Thank you for your time Ayush!


Re: Get the "target" property of shortcuts in a directory by Ayush

Ayush
Thu Jul 26 20:56:41 CDT 2007

[John] wrote-:

> Thank you for your time Ayush!

You're welcome John.

Good Luck, Ayush.
--
Regular Expression Syntax : http://snipurl.com/RegularExpr_Syntax