Jump to content

Help With Filegetver & Fileinstall (autoit3)


 Share

Recommended Posts

Group,

First, just want to say a big THANKS to all of you out there who have worked on and helped make AutoIt V3 what it is (and is becoming), your efforts are most appreciated.

Now for the 2nd reason for the e-mail. I need some suggestions on the following code, it works uncompiled, but I receive an error (sorry, it flashes to quick to see) when I try and compile it. :whistle:

$Scrver = '5.6.0.6626'

$Filever = FileGetVersion ( @SystemDir & "\Scrrun.Dll" )

If $Scrver = $Filever Then

FileOk($Scrver, $FileVer)

Else

NotOk($Scrver, $Filever)

EndIf

Func FileOK($Scrver, $FileVer)

SplashTextOn("File Version", "Version of Scrrun.Dll is correct.", 450, 90)

Sleep(3000)

SplashOff()

EndFunc

Func NotOk($Scrver, $Filever)

SplashTextOn("File Version", "Version of Scrrun.Dll is INCORRECT - Installing.", 450, 90)

Sleep(3000)

SplashOff()

FileInstall(@ScriptDir & "\Scrrun.Dll", @SystemDir & "\Scrrun.Dll") EndFunc Exit

Background:

Our internal software development team recently rolled out a new version of software that we use throughout the company. The problem arose when as part of their installation package they included an older version of the Scrrun.dll file (included with the Microsoft WSH 5.1). Our Enterprise is running WSH 5.6 as a general rule and the installation of this old file has caused problems with our Enterprise logon script which is a .VBS script called from a Logon.bat front end (NT4 Domain, what can I say...). This old version file is causing an error when we start the call of the .VBS file. My solution was to write and compile the AutoIt3 script and call it from the batch file front end, it would check the currently installed version of the file on the workstation and if not the version of the WSH 5.6 package, install the file from the compiled script (as this is a system file, I will need to insure that on Win2k and WinXP that the file is actually copied into the @SystemDir\DllCache folder). Thanks in advance...

Link to comment
Share on other sites

DOH!!! :whistle:

Nevermind... I found the solution to my own problem. Forgot about the fact that the fileinstall 'source' path cannot be a variable. I can't believe the amount of time I spent looking through posts and example scripts trying to find the solution to the issue. Oh well, its only time.

Link to comment
Share on other sites

First day user, so consider the source, but I am looking to bring myself up to speed. Changes made by me are in Bold Blue.

I did a copy/paste and ran your script. I made a modification on the last line to prevent the copy from executing. I made that a comment line. I then ran the file and it appeared to run OK.

I then compiled the file into an EXE. I ran the compiled version with the same result, it looked OK.

I removed the scrrun.dll and ran manually again. Got the message that it was incorrect, and copy would be processed. Appears OK. Recompiled, same results.

Moved scrrun.dll file to ScriptDir, removed comment to allow copy, and ran manually again. File was copied to folder as desired..runs OK.

Compiled file again, and got an error message: :evil:

Invalid File Install Function()

FileInstall(@ScriptDir & "\Scrrun.Dll", @SystemDir & "\Scrrun.Dll")

Reviewing the FileInstall function I see that :whistle: "The source path of the file to compile must be a string; it cannot be a variable. The destination path with trailing backslash can be a variable".

So I modified the FileInstall line to the following:

FileInstall("C:\Program Files\AutoIt3\Extra\Editors\TextPad" & "\Scrrun.Dll", @SystemDir & "\Scrrun.Dll")

Different error Message: :angry:

Error Adding File.

C:\Program Files\AutoIt3\Extra\Editors\TextPad (My ScriptDir right now)

So I modified it again to this:

FileInstall( "C:\Program Files\AutoIt3\Extra\Editors\TextPad\Scrrun.Dll" , @SystemDir & "\Scrrun.Dll")

:lmao: Compiled with no errors. The compiled script ran OK. :P

Problem solved! (IMHO)

Lesson learned: Be sure not to use a variable as the source in FileInstall function?

I feel that this has been a good first day for me with AutoIt3.

It's good to have a simple, non-critical (to me), no immediate need, type of problem to learn with.

Thanks for the opportunity to learn and to contribute. B)

Test was done on WIN98SE and AutoIt3, version is 3.0.94.0

Hope this was helpful.............good luck, Bob

Link to comment
Share on other sites

So I modified the FileInstall line to the following:

QUOTE 

FileInstall("C:\Program Files\AutoIt3\Extra\Editors\TextPad" & "\Scrrun.Dll", @SystemDir & "\Scrrun.Dll")

Different error Message: 

Error Adding File.

C:\Program Files\AutoIt3\Extra\Editors\TextPad (My ScriptDir right now)

So I modified it again to this:

QUOTE 

FileInstall( "C:\Program Files\AutoIt3\Extra\Editors\TextPad\Scrrun.Dll" , @SystemDir & "\Scrrun.Dll") 

Compiled with no errors. The compiled script ran OK. 

For the same reason you can't use a variable in the source path, you also can't use the concatenation operator: the compiler (or interpreter in the case of uncompiled scripts) doesn't know about variables or operators or anything of that nature. It has to be a pure string literal, no concatenation, no variables, nothing but a valid path in string format.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...