Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com Message-ID: <31b7d27905011911185d32b557@mail.gmail.com> Date: Wed, 19 Jan 2005 13:18:56 -0600 From: "DePriest, Jason R." Reply-To: "DePriest, Jason R." To: cygwin AT cygwin DOT com Subject: Re: looking for shell program to retrieve property info from windows files In-Reply-To: <20050119130300.GA3452@tishler.net> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit References: <200501181915090630 DOT 3FC77633 AT smtp DOT atl DOT yahoo DOT com> <20050119130300 DOT GA3452 AT tishler DOT net> X-IsSubscribed: yes I did something similar in perl. #!/usr/bin/perl # Version 1.0 # - It does what it does. use Digest::MD5 qw(md5_hex); use Win32::File; use Win32::File::VersionInfo; use Win32::FileTime; $fname = $ARGV[0]; print "\nFile: $fname"; if (! -e $fname) { print "\n\nI cannot find your file."; print "\nError!"; print "\nperl: $!\nos: $^E\n"; die; } Win32::File::GetAttributes("$fname",$fattr); #print "\nWin32::File::GetAttrubutes(\"$fname\",\$fattr) -> $fattr"; $finfo = Win32::File::VersionInfo::GetFileVersionInfo("$fname"); #print "\n\$finfo = Win32::File::VersionInfo::GetFileVersionInfo(\"$fname\") -> $finfo"; $ftime = Win32::FileTime->new("$fname"); #print "\n\$ftime = Win32::FileTime->new(\"$fname\") -> $ftime"; if ($finfo) { print "\nFile Version: ", $finfo->{FileVersion}; print "\nProduct Version: ", $finfo->{ProductVersion}; %Flags = $finfo->{Flags}; foreach $key (keys %Flags) { if ($Flags{$key}) { print "\nFlags: ", $key; } # end of if the value exists } # end of foreach flag print "\nOS: ", $finfo->{OS}; print "\nType: ", $finfo->{Type}; print "\nDate: ", $finfo->{Date}; my $lang = (keys %{$finfo->{Lang}})[0]; if ($lang) { print "\nLanguage: ", $lang; print "\nComments: ", $finfo->{Lang}{$lang}{Comments}; print "\nCompanyName: ", $finfo->{Lang}{$lang}{CompanyName}; print "\nFileDescription: ", $finfo->{Lang}{$lang}{FileDescription}; print "\nFileVersion: ", $finfo->{Lang}{$lang}{FileVersion}; print "\nInternalName: ", $finfo->{Lang}{$lang}{InternalName}; print "\nCopyright: ", $finfo->{Lang}{$lang}{Copyright}; print "\nTrademarks: ", $finfo->{Lang}{$lang}{Trademarks}; print "\nOriginalFilename: ", $finfo->{Lang}{$lang}{OriginalFilename}; print "\nProductName: ", $finfo->{Lang}{$lang}{ProductName}; print "\nProductVersion: ", $finfo->{Lang}{$lang}{ProductVersion}; print "\nPrivateBuild: ", $finfo->{Lang}{$lang}{PrivateBuild}; print "\nSpecialBuild: ", $finfo->{Lang}{$lang}{SpecialBuild}; } } # end of if else { print "\n\nI cannot get the file flags."; print "\nError!"; print "\nAre you sure this is a valid Microsoft Portable Executable (PE) file with valid version information?\n"; } if ($fattr) { $#attr = -1; if ($fattr & ARCHIVE) { push(@attr,"archive"); } if ($fattr & COMPRESSED) { push(@attr,"compressed"); } if ($fattr & DIRECTORY) { push(@attr,"directory"); } if ($fattr & HIDDEN) { push(@attr,"hidden"); } if ($fattr & NORMAL) { push(@attr,"normal"); } if ($fattr & OFFLINE) { push(@attr,"offline"); } if ($fattr & READONLY) { push(@attr,"readonly"); } if ($fattr & SYSTEM) { push(@attr,"system"); } if ($fattr & TEMPORARY) { push(@attr,"temporary"); } print "\nFile Attributes: ", join(", ",@attr); } else { print "\n\nI cannot get the file attributes."; print "\nError!"; print "\nperl: $!\nos: $^E\n"; } if ($ftime) { printf( "\nCreated : %4d/%02d/%02d %02d:%02d:%02d", $ftime->Create( 'year', 'month', 'day', 'hour', 'minute', 'second' ) ); printf( "\nAccessed : %4d/%02d/%02d %02d:%02d:%02d", $ftime->Access( 'year', 'month', 'day', 'hour', 'minute', 'second' ) ); printf( "\nModified : %4d/%02d/%02d %02d:%02d:%02d", $ftime->Modify( 'year', 'month', 'day', 'hour', 'minute', 'second' ) ); } # end of if else { print "\n\nI cannot get the file times."; print "\nError!"; print "\nperl: $!\nos: $^E\n"; } print "\nMD5 Checksum: ", md5_hex("$fname"); print "\n"; On Wed, 19 Jan 2005 08:03:00 -0500, Jason Tishler < [REMOVED] > wrote: > Jaye, > > On Tue, Jan 18, 2005 at 07:15:09PM -0500, Jaye Speaks wrote: > > does anyone know of a shell program to retrieve the property info from > > windows files. I need info like the fileversion or prodversion. > > No, so I wrote my own: > > $ version 'C:\Program Files\Microsoft Office\OFFICE11\WINPROJ.EXE' > Required Information: > ProductVersion = 11.0.2003.816 > FileVersion = 11.0.2003.816 > Optional Information: > > $ cygversion /mnt/c/Program\ Files/Microsoft\ Office/OFFICE11/WINPROJ.EXE > Required Information: > ProductVersion = 11.0.2003.816 > FileVersion = 11.0.2003.816 > Optional Information: > > See attached for the source and Makefile. > > Note the Makefile builds two executables: > > version.exe: Mingw executable > cygversion.exe: Cygwin executable > > Jason > > -- > PGP/GPG Key: http://www.tishler.net/jason/pubkey.asc or key servers > Fingerprint: 7A73 1405 7F2B E669 C19D 8784 1AFD E4CC ECF4 8EF6 > > -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/