#212357 - 2017-03-22 07:49 AM
False file version using GetFileVersion
|
Schavuit
Fresh Scripter
Registered: 2016-09-30
Posts: 14
Loc: South Korea
|
When using GetFileVersion on a windows 10 system and using Kixtart version 4.66 or 4.67 I get a false file version back. Below is a script I am using.
? '------ Entering Testscript.kix ------'
;************************************************************************
$RC=setoption("WOW64AlternateRegView","On")
$RC=setoption("Wow64FileRedirection","on")
$RC=setoption("WrapATEOL","on")
$RC=setoption("NoVarsinStrings","on")
$RC=setoption("NoMacrosinstrings","on")
?
? "Kix Version - " @kix
? "Windows OS - " @producttype + " " + iif(@onwow64,"64bit","32bit")
$SCRIPTPATH = "\\mycomputer123\C$\Users\me123\Desktop\myscript\Scripts"
;************************************************************************
;***** Call Functions.kix to load all custom functions *****
;************************************************************************
Call $SCRIPTPATH + "\Functions.kix"
;************************************************************************
;***** Windows 10 test *****
;************************************************************************
$GoodVersionNum = "10.0.10586.17"
$FilePath = "%windir%\System32\Mssign32.dll"
;************************************************************************
$FileVersion = GetFileVersion($FilePath, "BinFileVersion")
;************************************************************************
If $FileVersion <> "" AND instr($FileVersion_C, "Good")
$Patch = "Good"
Else
$Patch = "Bad"
EndIf
;************************************************************************
$Patch_T1 = " Patch 1 Installed version: " + $FileVersion + " Required version is: " + $GoodVersionNum
?
? "File path we are looking into"
? $FilePath
?
? "File's version that Kixtart can see"
? $FileVersion
?
? "File version and what it needs to be at."
? $Patch_T1
?
;************************************************************************
? '------ End of Testscript.kix ------'
?
This is what it returns after running the script
------ Entering Testscript.kix ------
Kix Version - 4.67
Windows OS - Windows 10 Enterprise 64bit
File path we are looking into
C:windowsSystem32Mssign32.dll
Files version that Kixtart can see
6.2.10586.17
File version and what it needs to be at.
Patch 1 Installed version: 6.2.10586.17 Required version is: 10.0.10586.17
------ End of Testscript.kix ------
* there are backslashes in the file path
The real file version for this .dll file is 10.0.10586.17
|
Top
|
|
|
|
#212360 - 2017-03-22 02:07 PM
Re: False file version using GetFileVersion
[Re: Schavuit]
|
Allen
KiX Supporter
Registered: 2003-04-19
Posts: 4549
Loc: USA
|
It is likely you are looking for a 32bit file. On a 64bit OS, System32 is the 64bit location of the file. Look in SysWow64 and see if you get better results.
%systemroot%\syswow64
I use the following UDF to avoid this problem.
function System32()
$System32="%systemroot%\" + iif(@onwow64,"syswow64","system32")
endfunction
|
Top
|
|
|
|
#212364 - 2017-03-23 01:15 AM
Re: False file version using GetFileVersion
[Re: Schavuit]
|
Allen
KiX Supporter
Registered: 2003-04-19
Posts: 4549
Loc: USA
|
|
Top
|
|
|
|
#212365 - 2017-03-23 03:34 AM
Re: False file version using GetFileVersion
[Re: Allen]
|
Schavuit
Fresh Scripter
Registered: 2016-09-30
Posts: 14
Loc: South Korea
|
I added in that function and it still sees it as the wrong file version
*note I added in the function into my function.kix script.*
? '------ Entering Testscript.kix ------'
;************************************************************************
$RC=setoption("WOW64AlternateRegView","on")
$RC=setoption("Wow64FileRedirection","on")
$RC=setoption("WrapATEOL","on")
$RC=setoption("NoVarsinStrings","on")
$RC=setoption("NoMacrosinstrings","on")
?
? "Kix Version - " @kix
? "Windows OS - " @producttype + " " + iif(@onwow64,"64bit","32bit")
$SCRIPTPATH = "\\mlwxw3-4220ly\C$\Users\1110211712A\Desktop\TCNO_Tracker_Tester\Scripts"
;************************************************************************
;***** Call Functions.kix to load all custom functions *****
;************************************************************************
Call $SCRIPTPATH + "\Functions.kix"
;************************************************************************
;***** Windows 10 test *****
;************************************************************************
$GoodVersionNum = "10.0.10586.17"
$FilePath = System32 + "\Mssign32.dll"
;************************************************************************
$FQFN = $FilePath
$attribute = 159
$FileVersion = GetExtFileProperties($FQFN, $attribute)
;************************************************************************
If $FileVersion <> "" AND instr($FileVersion_C, "Good")
$Patch = "Good"
Else
$Patch = "Bad"
EndIf
;************************************************************************
$Patch_T1 = " Patch 1 Installed version: " + $FileVersion + " Required version is: " + $GoodVersionNum
?
? "File path we are looking into"
? $FilePath
?
? "File's version that Kixtart can see"
? $FileVersion
?
? "File version and what it needs to be at."
? $Patch_T1
?
?
?
;************************************************************************
Output...
------ Entering Testscript.kix ------
Kix Version - 4.67
Windows OS - Windows 10 Enterprise 64bit
File path we are looking into
C:windowssyswow64Mssign32.dll
Files version that Kixtart can see
6.2.10586.17
File version and what it needs to be at.
Patch 1 Installed version: 6.2.10586.17 Required version is: 10.0.10586.17
|
Top
|
|
|
|
#212368 - 2017-03-23 10:06 AM
Re: False file version using GetFileVersion
[Re: Schavuit]
|
Arend_
MM club member
Registered: 2005-01-17
Posts: 1895
Loc: Hilversum, The Netherlands
|
159 works properly if you copy Mssign32.dll and rename it to Mssign32-Copy.dll or something. Which make this whole thing weird...
This points it out quicker:
? CreateObject("Scripting.FileSystemObject").GetFileVersion("C:\Windows\System32\mssign32 - Copy.dll")
? CreateObject("Scripting.FileSystemObject").GetFileVersion("C:\Windows\System32\mssign32.dll")
But luckily WMI doesn't fail
? GetObject("winmgmts:\\.\root\cimv2").ExecQuery("Select * from CIM_Datafile Where Name = 'c:\\windows\\system32\\mssign32.dll'").ItemIndex(0).Version
|
Top
|
|
|
|
#212370 - 2017-03-23 02:41 PM
Re: False file version using GetFileVersion
[Re: Arend_]
|
Allen
KiX Supporter
Registered: 2003-04-19
Posts: 4549
Loc: USA
|
The WMI Code in Function format.
function WMIFileVersion($FQFN)
dim $RC,$NVIS
$NVIS=setoption("NoVarsinstrings","On")
if exist($FQFN)
$RC=execute('$WMIFileVersion=GetObject("winmgmts:\\.\root\cimv2").ExecQuery("Select * from CIM_Datafile Where Name =' + "'" + $FQFN + "'" + '").ItemIndex(0).Version')
endif
$RC=setoption("NoVarsinstrings",$NVIS)
endfunction
Didn't look into it very deep, but even this one had trouble determining a version of at least one exe, it came back with nothing. At least there are options here.
|
Top
|
|
|
|
#212372 - 2017-03-24 01:09 AM
Re: False file version using GetFileVersion
[Re: Allen]
|
Schavuit
Fresh Scripter
Registered: 2016-09-30
Posts: 14
Loc: South Korea
|
Sweet deal Im now using (see below) in my code and it works!
? GetObject("winmgmts:\\.\root\cimv2").ExecQuery("Select * from CIM_Datafile Where Name = 'c:\\windows\\system32\\mssign32.dll'").ItemIndex(0).version
Thanks for all the help
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
0 registered
and 366 anonymous users online.
|
|
|