Page 1 of 1 1
Topic Options
#115331 - 2004-03-02 10:44 AM getfileversion not writing to log file
AzzerShaw Offline
Seasoned Scripter
****

Registered: 2003-02-20
Posts: 510
Loc: Cheltenham, England
Morning all

Ive wrote this simple check to get file versions from a couple of products but for some reason getfileversion doesnt seem to want to write to the log file?
Ive looked around but cant find anything? What am i doing wrong?

Any help would be appreciated,

Regards

Aaron

Code:
 
Break on

Open (1,"%systemdrive%\Temp\listpc.txt")
ReadLine(1)
ReadLine(1)
ReadLine(1)

Do
$CompName=ReadLine(1)
$compname = SubStr($compname,1,8)
;$compname = Trim($compname)

?"$compname"

$info = "C_Drive\Infoconn\accmgr\accmgr.exe"
$MyExtra = "C_Drive\program files\E!pc\sessions\experian.edp"
$ExpIrma = "C_Drive\infoconn\accmgr\IRMAMAIN.XWQ"

If Exist("$CompName\$info")=1
$InfoVer=GetFileVersion("$CompName\$info")
WriteProfileString("%systemdrive%\Temp\attachmate.Log","$Compname","16 bit Infoconnect Accessory Manager"," $InfoVer ")
EndIf

If Exist("$CompName\$MyExtra")=1
$MyExtVer=GetFileVersion("$CompName\$MyExtra")
WriteProfileString("%systemdrive%\Temp\attachmate.Log","$Compname","16 bit IRMA 3270 emulator(Experian) "," $MyExtVer ")
EndIf

If Exist("$CompName\$ExpIrma")=1
$ExpIrma=GetFileVersion("$CompName\$ExpIrma")
WriteProfileString("%systemdrive%\Temp\attachmate.Log","$Compname","32 bit myExtra 3270 emulator (Experian)"," $ExpIrma ")
EndIf

Until $CompName = ""

_________________________
If at first you don't succeed, try again. Then quit. There's no use being a damn fool about it. - W.C Fields

Top
#115332 - 2004-03-02 11:00 AM Re: getfileversion not writing to log file
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
First thing you need to do is check the error value on return from both WriteProfileString() and GetFileVersion() and handle any errors.

This will immediately point you in the right direction - probably path failure or permissions problems.

Top
#115333 - 2004-03-02 11:10 AM Re: getfileversion not writing to log file
AzzerShaw Offline
Seasoned Scripter
****

Registered: 2003-02-20
Posts: 510
Loc: Cheltenham, England
Writeprofile string is fine cause it does find the file and does write and therefore the path in the GetFileVersion must be correct. But it isnt even if i do "?filever" it doesnt come up. Also confirmed this by putting the path in manually rather then using a variable. Defo not permissions problem.
I even added GetFileVersion ("file name","fileversion")and it still dont work.
_________________________
If at first you don't succeed, try again. Then quit. There's no use being a damn fool about it. - W.C Fields

Top
#115334 - 2004-03-02 11:13 AM Re: getfileversion not writing to log file
AzzerShaw Offline
Seasoned Scripter
****

Registered: 2003-02-20
Posts: 510
Loc: Cheltenham, England
Just added error checking and it comes back 0
_________________________
If at first you don't succeed, try again. Then quit. There's no use being a damn fool about it. - W.C Fields

Top
#115335 - 2004-03-02 11:18 AM Re: getfileversion not writing to log file
AzzerShaw Offline
Seasoned Scripter
****

Registered: 2003-02-20
Posts: 510
Loc: Cheltenham, England
Just realised why. Script was fine but the file doesnt return anything. Changed the file location to something like Word and it works fine. Damn.....

Weird though cause if I do a right click on the file, it does have a file version. Is there any reason for this not returning anything?


Edited by AzzerShaw (2004-03-02 11:21 AM)
_________________________
If at first you don't succeed, try again. Then quit. There's no use being a damn fool about it. - W.C Fields

Top
#115336 - 2004-03-02 11:29 AM Re: getfileversion not writing to log file
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
There is a known problem with GetFileVersion() in that it may not work for in-use (open) files.

If this is a problem for you, search the forums for a method using FSO which should help you.

Top
#115337 - 2004-03-02 12:09 PM Re: getfileversion not writing to log file
AzzerShaw Offline
Seasoned Scripter
****

Registered: 2003-02-20
Posts: 510
Loc: Cheltenham, England
I think I remember something like that being mentioned before now.

I'll try and run the script overnight and see if that works. Thanks Rich.
_________________________
If at first you don't succeed, try again. Then quit. There's no use being a damn fool about it. - W.C Fields

Top
#115338 - 2004-03-03 03:18 AM Re: getfileversion not writing to log file
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Code:
Break on
$BasePath = "%windir%\system32\config\"
$strFile = "appevent.evt","secevent.evt","sysevent.evt"
For each $element in $strFile
GetAllFileProperties($BasePath+$element)
Next
get $_

For each $element in $strFile
? $BasePath + $element + " size = "
GetFileSize($BasePath + $element)
? $BasePath + $element + " time = "
GetFileTime($BasePath + $element)
Next
get $_

Function GetAllFileProperties($FileName)
$fso = CreateObject("Scripting.FileSystemObject")
$objFile = $fso.GetFile($FileName)
? "Date created: " + $objFile.DateCreated
? "Date last accessed: " + $objFile.DateLastAccessed
? "Date last modified: " + $objFile.DateLastModified
? "Drive: " + $objFile.Drive
? "Name: " + $objFile.Name
? "Parent folder: " + $objFile.ParentFolder
? "Path: " + $objFile.Path
? "Short name: " + $objFile.ShortName
? "Short path: " + $objFile.ShortPath
? "Size: " + $objFile.Size
? "Type: " + $objFile.Type
EndFunction

_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#115339 - 2004-03-03 10:43 AM Re: getfileversion not writing to log file
AzzerShaw Offline
Seasoned Scripter
****

Registered: 2003-02-20
Posts: 510
Loc: Cheltenham, England
Many thanks Les!!
_________________________
If at first you don't succeed, try again. Then quit. There's no use being a damn fool about it. - W.C Fields

Top
#115340 - 2004-03-03 11:01 AM Re: getfileversion not writing to log file
AzzerShaw Offline
Seasoned Scripter
****

Registered: 2003-02-20
Posts: 510
Loc: Cheltenham, England
Can you tell me what $element is meant to be ? I can kinda of get my head round the rest its just that variable?

Thanks

Aaron
_________________________
If at first you don't succeed, try again. Then quit. There's no use being a damn fool about it. - W.C Fields

Top
#115341 - 2004-03-03 11:09 AM Re: getfileversion not writing to log file
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
There's some KiXtart shorthand going on that you may have missed.

This line is creating an array of filenames called $strFile:
Quote:

$strFile = "appevent.evt","secevent.evt","sysevent.evt"




The next line is simply a For..Next structure which runs for each item in the $strFile array:
Quote:

For each $element in $strFile



On each iteration it assigns the next array element to the variable $element.

This means, that on the first pass $element is "appevent.evt", on the second pass it is "secevent.evt" and so-on.

Les is using the loop twice, once to get some info via FSO, and then again to get some info via KiXtart built-ins.

Top
#115342 - 2004-03-03 11:11 AM Re: getfileversion not writing to log file
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
check on manual for proper documentation of for-each and for-to

if we are talking about for each, it scans through all elements in array.
the variable named (for each VARIABLE in ARRAY) is the varname used to receive this array element.
it changes on each loop (like the for-each name already says) incrementing from starting element (0) to the last one (ubound)
_________________________
!

download KiXnet

Top
#115343 - 2004-03-03 12:06 PM Re: getfileversion not writing to log file
AzzerShaw Offline
Seasoned Scripter
****

Registered: 2003-02-20
Posts: 510
Loc: Cheltenham, England
Cheers Guys, I'll have a read up as soon as my hangover goes away and my eyesight returns.....groan....
_________________________
If at first you don't succeed, try again. Then quit. There's no use being a damn fool about it. - W.C Fields

Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 1046 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.062 seconds in which 0.014 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org