in reply to Windows Net Use

here is a kind of quick and dirty utility to use the WMIC NETUSE command to do things. not meant to be pretty - just present the data.

use strict; my %netuse_from_wmic; my @wmic_output=`WMIC NETUSE LIST FULL /FORMAT:CSV`; my @title_data; my $LocalNameIndex; foreach my $wmic_line (@wmic_output) { chomp $wmic_line; $wmic_line=~s/\r$//; next if $wmic_line eq ""; if(0==scalar @title_data) { @title_data=split /,/,$wmic_line; for(my $idx=0;$idx<scalar @title_data;$idx++) { print "$idx=$title_data[$idx]\n"; $LocalNameIndex=$idx if $title_data[$idx]=~/^LocalName$/i; } die "no LocalName found in title" if !defined $LocalNameIndex; } else { my @wmic_netuse_entry=split /,/,$wmic_line; for(my $idx=0;$idx<scalar @title_data;$idx++) { $netuse_from_wmic{uc $wmic_netuse_entry[$LocalNameIndex]}{ +$title_data[$idx]}=$wmic_netuse_entry[$idx]; } } } foreach my $drive (sort keys %netuse_from_wmic) { print "Drive: $drive\n"; foreach my $value (sort keys %{$netuse_from_wmic{$drive}}) { print " $value=$netuse_from_wmic{$drive}{$value}\n"; } }