Windows Vista Forums
Vista Forums Home Join Vista Forums Donate Vista Tutorials Tags

Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
Register at Vista forums...the world biggest Windows Vista resource Join Vista Forums Now

Go Back   Vista Forums > Microsoft Technical Newsgroups > PowerShell

get version of an executable created using .net

Update your Vista Drivers Update Your Drivers Now!!
Closed Thread
 
Thread Tools Display Modes
Old 01-09-2007   #1 (permalink)
secretGeek
Guest


 

get version of an executable created using .net

Hello Powershell Superstars.

i'm trying to work out how to find the version of an executable file (that
was created using .net)

I can return a 'versionInfo' property -- but that doesn't seem to be what
I'm after (and is blank).

I'm after the same version information I get in windows XP when I right
click on an executable, and select properties. There's a 'Version' tab that
contains "File Version" and 'Other Version information" -- where quite a bit
of the assembly metadata is displayed.

i haven't yet found out how to get to this info from a power shell script.

I've been watching this list avidly for a long time -- what a great
community around Powershell!!

cheers
lb .:: secretGeek.net :: dot Nuts about dot Net ::.




My System SpecsSystem Spec
Old 01-10-2007   #2 (permalink)
Keith Hill [MVP]
Guest


 

Re: get version of an executable created using .net

"secretGeek" <secretGeek@discussions.microsoft.com> wrote in message newsB42939F-E141-4D1B-A8A7-E9B330606BCC@microsoft.com...
> Hello Powershell Superstars.
>
> i'm trying to work out how to find the version of an executable file (that
> was created using .net)
>
> I can return a 'versionInfo' property -- but that doesn't seem to be what
> I'm after (and is blank).
>
> I'm after the same version information I get in windows XP when I right
> click on an executable, and select properties. There's a 'Version' tab that
> contains "File Version" and 'Other Version information" -- where quite a bit
> of the assembly metadata is displayed.
>
> i haven't yet found out how to get to this info from a power shell script.
>
> I've been watching this list avidly for a long time -- what a great
> community around Powershell!!


You can get this natively using the Get-Command cmdlet:

33> gcm PowerShell | %{$_.FileVersionInfo} |fl


OriginalFilename : PowerShell.EXE
FileDescription : PowerShell.EXE
ProductName : Microsoft® Windows® Operating System
Comments :
CompanyName : Microsoft Corporation
FileName : C:\WINDOWS\system32\WindowsPowerShell\v1.0\powershell.exe
FileVersion : 6.0.5430.0 (winmain(wmbla).060830-0116)
ProductVersion : 6.0.5430.0
IsDebug : False
IsPatched : False
IsPreRelease : False
IsPrivateBuild : True
IsSpecialBuild : False
Language : English (United States)
LegalCopyright : © Microsoft Corporation. All rights reserved.
LegalTrademarks :
PrivateBuild :
SpecialBuild :

However this is kind of buried. In the next version of PowerShell Community Extensions we have a Get-FileVersionInfo cmdlet. Of course the implementation is dirt simple. You could do this in script like so:

35> [Diagnostics.FileVersionInfo]::GetVersionInfo((resolve-path $pshome\powershell.exe)) | fl

--
Keith
My System SpecsSystem Spec
Old 01-10-2007   #3 (permalink)
Keith Hill [MVP]
Guest


 

Re: get version of an executable created using .net

Even simpler:

36> gcm powershell | fl

--
Keith
"Keith Hill [MVP]" <r_keith_hill@mailhot.moc.nospam> wrote in message news:O5jQu5HNHHA.2232@TK2MSFTNGP02.phx.gbl...
"secretGeek" <secretGeek@discussions.microsoft.com> wrote in message newsB42939F-E141-4D1B-A8A7-E9B330606BCC@microsoft.com...

33> gcm PowerShell | %{$_.FileVersionInfo} |fl
My System SpecsSystem Spec
Old 01-10-2007   #4 (permalink)
secretGeek
Guest


 

Re: get version of an executable created using .net

This is great information Keith -- but not quite what I'm asking for.

It's not powershell itself that I want to determine the version of -- it's
various other executables created using .net, that my client has on their
network.

say there's an executable called "LineOfBusiness.exe"

gcm LineOfBusiness

won't work ("The term 'LineOfBusiness' is not recognised as a cmdlet,
function... etc")

And even

get-childItem LineOfBusiness.exe | format-list VersionInfo

returns a blank value for version info.

Yet -- when I look at any of these executables via explorer, i can see the
version information. I think it must be accessible in some other way.

cheers
lb

"Keith Hill [MVP]" wrote:

> Even simpler:
>
> 36> gcm powershell | fl
>
> --
> Keith
> "Keith Hill [MVP]" <r_keith_hill@mailhot.moc.nospam> wrote in message news:O5jQu5HNHHA.2232@TK2MSFTNGP02.phx.gbl...
> "secretGeek" <secretGeek@discussions.microsoft.com> wrote in message newsB42939F-E141-4D1B-A8A7-E9B330606BCC@microsoft.com...
>
> 33> gcm PowerShell | %{$_.FileVersionInfo} |fl

My System SpecsSystem Spec
Old 01-10-2007   #5 (permalink)
secretGeek
Guest


 

Re: get version of an executable created using .net

Wait a moment!! You did solve it -- thanks Keith.

When I tried (for example)

gcm 'c:\Program Files\Business\LineOfBusiness.exe' | fl

i got the answer I was after....
so fully qualifying the name was required (even though i was located in the
same folder as the executable)

thanks keith -- I take back all the curse words ;-)

lb

"Keith Hill [MVP]" wrote:

> Even simpler:
>
> 36> gcm powershell | fl
>
> --
> Keith
> "Keith Hill [MVP]" <r_keith_hill@mailhot.moc.nospam> wrote in message news:O5jQu5HNHHA.2232@TK2MSFTNGP02.phx.gbl...
> "secretGeek" <secretGeek@discussions.microsoft.com> wrote in message newsB42939F-E141-4D1B-A8A7-E9B330606BCC@microsoft.com...
>
> 33> gcm PowerShell | %{$_.FileVersionInfo} |fl

My System SpecsSystem Spec
Old 01-10-2007   #6 (permalink)
secretGeek
Guest


 

Re: get version of an executable created using .net

and to run this for a bunch of executables this works:

gci *.exe | resolve-path | gcm | %{$_.FileVersionInfo} |fl ProductName,
ProductVersion

ahhh ! this is fun and exciting stuff.

cheers



"secretGeek" wrote:

> Wait a moment!! You did solve it -- thanks Keith.
>
> When I tried (for example)
>
> gcm 'c:\Program Files\Business\LineOfBusiness.exe' | fl
>
> i got the answer I was after....
> so fully qualifying the name was required (even though i was located in the
> same folder as the executable)
>
> thanks keith -- I take back all the curse words ;-)
>
> lb
>
> "Keith Hill [MVP]" wrote:
>
> > Even simpler:
> >
> > 36> gcm powershell | fl
> >
> > --
> > Keith
> > "Keith Hill [MVP]" <r_keith_hill@mailhot.moc.nospam> wrote in message news:O5jQu5HNHHA.2232@TK2MSFTNGP02.phx.gbl...
> > "secretGeek" <secretGeek@discussions.microsoft.com> wrote in message newsB42939F-E141-4D1B-A8A7-E9B330606BCC@microsoft.com...
> >
> > 33> gcm PowerShell | %{$_.FileVersionInfo} |fl

My System SpecsSystem Spec
Closed Thread

Thread Tools
Display Modes



Similar Threads
Thread Thread Starter Forum Replies Last Post
Files created by Powershell are over 2X bigger than files created bytext editor or cmd.exe. tom.luxury PowerShell 4 05-27-2008 05:06 AM
time executable jo Vista General 0 05-02-2008 09:49 PM
run executable Jean-Marc PowerShell 1 03-07-2007 10:26 PM
Executable Paka Vista General 2 03-02-2007 08:43 AM
Signing an executable Hendrik Schober Vista security 18 05-09-2006 03:35 PM


Update your Vista Drivers Update Your Drivers Now!!

Vistax64.com is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media 2005-2008