Jump to content

Checking for online updates


Recommended Posts

The script is pretty obvious, I think. I'm new to scripting and I'm trying to keep it lean (and self-educational) at the same time.

The errors I'm getting has to do with, I'm pretty sure, the mis-use of the Dim statement. What should it be? Any suggestions on how I can clean this up?

Error: Variable used without being declared

;Script's purpose is to check for updates online. 

;If file sizes don't match, assume there's an update and download it to the directory.

XCleaner()

Blockfile()

HijackThis()

Exit

Func HijackThis()

Dim $name='HijackThis.exe'

Dim $site='http://www.spywareinfo.com/~merijn/files/' & $name

Dim $dir='F:\System CD\Spy\' & $name

Seek()

EndFunc

Func Blockfile()

Dim $name='blocklist.reg'

Dim $site='http://www.spywareguide.com/' & $name

Dim $dir='F:\System CD\Spy\' & $name

Seek()

EndFunc

Func xcleaner()

Dim $name='xclean_micro.exe'

Dim $site='http://www.xblock.com/download/' & $name

Dim $dir='F:\System CD\Spy\' & $name

Seek()

EndFunc

Func Seek()

msgbox("Size", $site, $dir)

$sizeweb = InetGetSize($site)

$sizehome = FileGetSize($dir)

if $sizeweb <> $sizehome Then

TrayTip("Updating",$name,3)

InetGet($site,$dir,1,0)

EndIf

EndFunc

Edited by Xander
Link to comment
Share on other sites

One Way:

;Script's purpose is to check for updates online.
;If file sizes don't match, assume there's an update and download it to the directory.

Global $name
Global $site
Global $dir

XCleaner()
Blockfile()
HijackThis()
Exit

Func HijackThis()
    $name='HijackThis.exe'
    $site='http://www.spywareinfo.com/~merijn/files/' & $name
    $dir='F:\System CD\Spy\' & $name
    Seek()
EndFunc  ;==>HijackThis

Func Blockfile()
    $name='blocklist.reg'
    $site='http://www.spywareguide.com/' & $name
    $dir='F:\System CD\Spy\' & $name
    Seek()
EndFunc  ;==>Blockfile

Func xcleaner()
    $name='xclean_micro.exe'
    $site='http://www.xblock.com/download/' & $name
    $dir='F:\System CD\Spy\' & $name
    Seek()
EndFunc  ;==>xcleaner

Func Seek()
    msgbox("Size", $site, $dir)
    $sizeweb = InetGetSize($site)
    $sizehome = FileGetSize($dir)
    if $sizeweb <> $sizehome Then
        TrayTip("Updating",$name,3)
        InetGet($site,$dir,1,0)
    EndIf
EndFunc  ;==>Seek
Link to comment
Share on other sites

My mistake was the not understanding the GLOBAL command.

I'd seen it in examples of "Global $var = ..." and thought that the variable had to be defined at the start, and that that variable was then unchanging throughout the whole script.

Before coming back here, I had just tried using Global instead of Dim or Local before my vars and it had worked. Your suggestion shaves off a few characters overall.

One more thing learned!

I already have the compiled script set up as a weekly task to keep my install files up to date.

While there might be better ways to determing whether or not an update is available (small chance that the update is the exact same size as the last one), this seems to work quite well.

Incidentally, if anyone can suggest any other commonly used files, I'd be glad to hear from you.

Edited by Xander
Link to comment
Share on other sites

bshoenhair,

Nice and simple rearrangement of code. It works great after I modifed it for some programs that I use. Also, I have been thinking of doing some similar code, but you all beat me to it. Thanks for the thread...

Always leaning something new..

Cheers. :-)

Link to comment
Share on other sites

Incidentally, if anyone can suggest any other commonly used files, I'd be glad to hear from you.

<{POST_SNAPBACK}>

Here are some utils that I really like to add to my system. Some are XP-only apps.

http://www.xp-antispy.org - XP-Antispy - Disables M$ Spy functionality

http://www.aignes.com/deadlink.htm - AMDeadLink - Bookmark Manager

http://www.daemon-tools.cc/dtcc/portal/portal.php - Daemon Tools - CD Emulator

http://www.larshederer.homepage.t-online.de/erunt/ - ERUNT - Registry/Profile backup util (Saved my butt many times)

http://scintilla.sourceforge.net/SciTEDoc.html - SciTE - AutoIt Editor

Hope you find these of interest.. BTW, they are all Freeware

Cheers..

Link to comment
Share on other sites

From the help file

Not all servers will correctly give the filesize, especially when using a proxy server.

I have experienced that the odds are against you if you use the comparison of "$sizeweb <> $sizehome". I use is a 1KB differencial ratio which seems to work better due to server inconsistency filesize that InetGetSize returns.

Link to comment
Share on other sites

  • Developers

http://scintilla.sourceforge.net/SciTEDoc.html - SciTE - AutoIt Editor

<{POST_SNAPBACK}>

This is the link to the SciTE WebSite, but when you are looking for the special installer for SciTE4AutoIt3 containing all the extra settings and utilities its better to check : http://www.autoitscript.com/autoit3/scite/

:)

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

From the help file

Not all servers will correctly give the filesize, especially when using a proxy server.

I have experienced that the odds are against you if you use the comparison of "$sizeweb <> $sizehome". I use is a 1KB differencial ratio which seems to work better due to server inconsistency filesize that InetGetSize returns.

<{POST_SNAPBACK}>

Nice idea. How would you script that?

Busysignal, thanks for the ideas. In context of the thread, I was thinking of programs that get used regularly and updated often.

Edited by Xander
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...