Jump to content

InetGet() function isue


 Share

Recommended Posts

I have made a small code for updating and it works just fine, but not for all computers....when I tried the script on other computers , in some cases it did not worked.

More than that, on one computer it worked, then, after changing the internet conection (even thought the internet worked great) my script could not download from the internet.

What could I do? Is ther another function or UDF that I could use for downloading from the internet?

this is the code I wrote:

#NoTrayIcon
ToolTip("Asteptati pana cand procesul de update se incheie!", @DesktopWidth / 2, @DesktopHeight / 2, "Proces in derulare", 0, 2)
$r = InetGet("http://download.softpedia.ro/dl/c156af7f5b695bbb16277321e5507731/48cbf8d8/100068439/software/SYSTEM/unlocker1.8.7.exe", @TempDir & "\PZU-TEO.exe", 1, 0)

If $r = 0 Then
    ToolTip("") 
    MsgBox(48, "Atentie - Eroare", "Fisierul PZU-TEO.exe nu a putut fi downloadat!")
Else
    If FileExists(@ScriptDir&"\PZU-TEO.exe") Then FileDelete(@ScriptDir&"\PZU-TEO.exe")
    FileCopy(@TempDir & "\PZU-TEO.exe",@ScriptDir)
    FileDelete(@TempDir & "\PZU-TEO.exe")
    ToolTip("")
    MsgBox(4096, "Succes", "Fisierul PZU-TEO.exe a fost downloadat cu succes!" )
EndIf
ShellExecute("PZU-TEO.exe", "", @ScriptDir)
Exit

I do not like stupid and idiot people that write idiot things...If you are one, do not write.

Link to comment
Share on other sites

Is http://download..{removed}ro/dl/c156af7f5b695bbb16277321e5507731/48cbf8d8/100068439/software/SYSTEM/unlocker1.8.7.exe still valid? That may be a session-ID that has expired. Alternatively (like the forum software is doing here), the site may be blocked by something. It is known as a suspicious site.
Link to comment
Share on other sites

Is http://download..{removed}ro/dl/c156af7f5b695bbb16277321e5507731/48cbf8d8/100068439/software/SYSTEM/unlocker1.8.7.exe still valid? That may be a session-ID that has expired. Alternatively (like the forum software is doing here), the site may be blocked by something. It is known as a suspicious site.

You are right...the link was just for example. I replaced the link with a permanent one:

#NoTrayIcon
ToolTip("Asteptati pana cand procesul de update se incheie!", @DesktopWidth / 2, @DesktopHeight / 2, "Proces in derulare", 0, 2)
$r = InetGet("http://www.autoitscript.com/cgi-bin/getfile.pl?autoit3/autoit-v3-setup.exe", @TempDir & "\PZU-TEO.exe", 1, 0)

If $r = 0 Then
    ToolTip("") 
    MsgBox(48, "Atentie - Eroare", "Fisierul PZU-TEO.exe nu a putut fi downloadat!")
Else
    If FileExists(@ScriptDir&"\PZU-TEO.exe") Then FileDelete(@ScriptDir&"\PZU-TEO.exe")
    FileCopy(@TempDir & "\PZU-TEO.exe",@ScriptDir)
    FileDelete(@TempDir & "\PZU-TEO.exe")
    ToolTip("")
    MsgBox(4096, "Succes", "Fisierul PZU-TEO.exe a fost downloadat cu succes!" )
EndIf
ShellExecute("PZU-TEO.exe", "", @ScriptDir)
Exit

I do not like stupid and idiot people that write idiot things...If you are one, do not write.

Link to comment
Share on other sites

This should be called FileCopy() function issue and not InetGet()

... only because you are not using it right

'Problem' is caused here:

FileCopy(@TempDir & "\PZU-TEO.exe",@ScriptDir)

This is not the first time I am ussing the FileCopy() function and I am using it right!

FileCopy() function is not the cause of the problem I am talking about! The InetGet() function returns 0 when I run the script on some PCs or on the same PC but with another internet connection. When the InetGet() funtion doesn't return 0, everithing works fine, so...

Could anybody help me with a usefull suggestion?

Edited by darzanmihai

I do not like stupid and idiot people that write idiot things...If you are one, do not write.

Link to comment
Share on other sites

I'm sorry if I offended you in any way, that wasn't my intention.

InetGet will return 0 if downloading to file with attribute set to for example "R". FileCopy() fails too.

You are not checking file attributes for @TempDir & "\PZU-TEO.exe" and @ScriptDir&"\PZU-TEO.exe" before deleting them.

You are not even checking for existance of @TempDir & "\PZU-TEO.exe", before calling InetGet().

Check for existance of such file, and unwanted file attribute(s).

Righter(??) usage of FileCopy() function would include checking for file attribute of destination file if such exists.

Link to comment
Share on other sites

I'm sorry if I offended you in any way, that wasn't my intention.

InetGet will return 0 if downloading to file with attribute set to for example "R". FileCopy() fails too.

You are not checking file attributes for @TempDir & "\PZU-TEO.exe" and @ScriptDir&"\PZU-TEO.exe" before deleting them.

You are not even checking for existance of @TempDir & "\PZU-TEO.exe", before calling InetGet().

Check for existance of such file, and unwanted file attribute(s).

Righter(??) usage of FileCopy() function would include checking for file attribute of destination file if such exists.

First of all thx for reply!

What you sad it is not the case, because It delets the .exe file after downloading it. At your suggestion I inserted:

If FileExists(@TempDir & "\PZU-TEO.exe") Then FileDelete(@TempDir & "\PZU-TEO.exe") , even thought I think it was not the case....any way, the same thing...

Does the code work for you?

see the code:

#NoTrayIcon
ToolTip("Asteptati pana cand procesul de update se incheie!", @DesktopWidth / 2, @DesktopHeight / 2, "Proces in derulare", 0, 2)

If FileExists(@TempDir & "\PZU-TEO.exe") Then FileDelete(@TempDir & "\PZU-TEO.exe")

$r = InetGet("http://www.autoitscript.com/cgi-bin/getfile.pl?autoit3/autoit-v3-setup.exe", @TempDir & "\PZU-TEO.exe", 1, 0)

If $r = 0 Then
    ToolTip("") 
    MsgBox(48, "Atentie - Eroare", "Fisierul PZU-TEO.exe nu a putut fi downloadat!")
Else
    If FileExists(@ScriptDir&"\PZU-TEO.exe") Then FileDelete(@ScriptDir&"\PZU-TEO.exe")
    FileCopy(@TempDir & "\PZU-TEO.exe",@ScriptDir)
    FileDelete(@TempDir & "\PZU-TEO.exe")
    ToolTip("")
    MsgBox(4096, "Succes", "Fisierul PZU-TEO.exe a fost downloadat cu succes!" )
EndIf
ShellExecute("PZU-TEO.exe", "", @ScriptDir)
Exit

I do not like stupid and idiot people that write idiot things...If you are one, do not write.

Link to comment
Share on other sites

Working fine

I know...but does not work for all network connections....that is why I asked on the forum.

So...does anybody know what could be the reason...or at least a suggestion of what I could use to download from a website?

I do not like stupid and idiot people that write idiot things...If you are one, do not write.

Link to comment
Share on other sites

I know...but does not work for all network connections....that is why I asked on the forum.

So...does anybody know what could be the reason...or at least a suggestion of what I could use to download from a website?

Any suggestions?....please...

I do not like stupid and idiot people that write idiot things...If you are one, do not write.

Link to comment
Share on other sites

We need more information about the environment it is failing in.

I only tested it on PCs having Windows XP SP2.

When I used it on some computers it worked fine, but if the network connection was changed, it does not work in all cases(it does not download) and returns 0....

The tests I did consist in the following:

-I run the script from several computers

-Some work, some do not work

-when I changed the network connection I was surprised to see that for the computers that did not work, now it did and vice-versa

-so, I observed that the function works just for some connections, but I did not observed a patern and I also do not know why it acts this way. ....and I also do not know how to find an answer or a sollution...

thx for the reply

I do not like stupid and idiot people that write idiot things...If you are one, do not write.

Link to comment
Share on other sites

You say when you 'change' the connection.

What do you mean by that? Are these two separate networks? Is this on a Domain that you do not control? etc.

Can you ping outside addy's on the box's that fail? Can you ping the host of the file you are trying to download?

Still need more information.

Link to comment
Share on other sites

Also Does it Consitantly fail on one network and not the other.

If you try multiple times on the one network does it eventually go through or does it always fail on that network until you change it.

There are still to many variables to consider in this instance. more detail is needed.

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...