Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > Need to change icons on 400 + shortcuts

Thread Tools

Need to change icons on 400 + shortcuts

Posts: n/a
We have menus with 400 + shortcuts on them that are on a network
drive. We use folder redirection in a group policy in the AD to get
all PCs to look here for their menus. We are looking for a better way
as there is a 10+ second delay after clicking start|programs before
anything displays) but until then I need to do two things

1) check that the path to the icons file is to a valid file
2) change the path to a local .ico file with all the icons in it.(and
eventually set up the menus to be copied locally too) (Can't use
mandatory profiles as users require cached details to log in to
laptops at home.)

I've used the following code that I've copied /combined off the net to
walk the program files directory tree and return the icon for
each .lnk file it finds.

It has two problems

1) Not all folders are recognised as folders. There doesn't seem to
be a pattern here. I can't see why some are listed as DIRs and some
as FILEs. Those recognised as files obviously don't get walked.
2) I think the read_shortcut subroutine requires an absolute path but
my current working directoy (&cwd) only appears to return the parent

I'm running v5.8.8 built for MSWin32-x86-multi-thread on WIndows XP
The program files are on a windows share on a 2k3 server.

Any ideas appreciated.

DIR>> Business & Economics
LNK>> Business Plan.lnk
path : Y:/StartMenu/Programs/Business & Economics/Business Plan.lnk
Icon : C:\WINDOWS\explorer.exe,10
LNK>> Economics Today Volumes 7 8 and 9.lnk
path : Y:/StartMenu/Programs/Economics Today Volumes 7 8 and 9.lnk
Icon : ,0
LNK>> Go Chancellor!!!.lnk
path : Y:/StartMenu/Programs/Go Chancellor!!!.lnk
Icon : ,0
LNK>> Nuffield BP.lnk
path : Y:/StartMenu/Programs/Nuffield BP.lnk
Icon : ,0
FILE CorelDRAW Graphics Suite 12

#!/usr/bin/perl -s
use Win32::OLE;
use Cwd; # module for finding the current working directory

my $wsh = new Win32::OLE 'WScript.Shell';

sub read_shortcut {
my $lnk_path = shift; # path of existing .lnk file

my $shcut = $wsh->CreateShortcut($lnk_path) or die;
# $shcut->TargetPath

# This subroutine takes the name of a directory and recursively scans
# down the filesystem from that point looking for files named "core"
sub ScanDirectory{
my ($workdir) = shift;

my ($startdir) = &cwd; # keep track of where we began

chdir($workdir) or die "Unable to enter dir $workdir:$!\n";
opendir(DIR, ".") or die "Unable to open $workdir:$!\n";
my @names = readdir(DIR) or die "Unable to read $workdir:$!\n";

foreach my $name (@names){
next if ($name eq ".");
next if ($name eq "..");

if (-d $name){ # is this a directory?
print "DIR>> ".$name."\n";
# $name =~ s/ /\\ /;
# print ">>DIR ".$name."\n";

if ($name =~ m/.lnk/) { # does this filename
have .lnk in it
print "LNK>> ".$name."\n";
print "path : ".$mypath."\n";
print " Icon : ".read_shortcut("$mypath")."\n";
else {
print " FILE ".$name."\n";
chdir($startdir) or
die "Unable to change to dir $startdir:$!\n";



Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Windows 2000 - Problem with changing folder icons (shortcuts OK) Ian Jackson Computer Support 4 05-01-2005 06:03 PM
How does ISO 400 in Digital Rebel compare to ISO 400 film? Veggie Digital Photography 19 08-23-2004 11:38 AM
Shortcuts and non-shortcuts. Patrick D. Rockwell Computer Support 14 07-04-2004 04:49 PM
Olympus Stylus 300/ 400 (mju 300 / 400) carry case Clive Long,UK Digital Photography 1 10-11-2003 01:33 AM
dr("field").toString returns "400.0000" instead of "400" Dan C Douglas ASP .Net 5 07-22-2003 05:48 PM