UrlDownloadToFile does nothing Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
glen

UrlDownloadToFile does nothing

21 Jul 2018, 09:41

Here is my code:

Code: Select all

UrlDownloadToFile, https://autohotkey.com/download/1.1/version.txt, C:\AutoHotkey Latest Version.txt
When I run it, nothing happens.

I have IE installed and I've tried disabling my antivirus. I have no clue why it's not working.

Can you help please?
gregster
Posts: 8999
Joined: 30 Sep 2013, 06:48

Re: UrlDownloadToFile does nothing

21 Jul 2018, 09:58

It's a guess (because I don't know your system details), but the root directory is often protected from non-admin users... and scripts (you can try copying a text file there, a warning box might appear). Either choose another directory ('Documents' or something you are allowed to write to) or try to run the script as 'admin'...
Last edited by gregster on 21 Jul 2018, 10:00, edited 1 time in total.
garry
Posts: 3763
Joined: 22 Dec 2013, 12:50

Re: UrlDownloadToFile does nothing

21 Jul 2018, 10:00

EDIT
Gregster wrote : this is it
...but the root directory is often protected from non-admin users... and scripts (you can try copying a text file there, a warning box might appear).
Either choose another directory ('Documents' or something you are allowed to write to) or try to run the script as 'admin'...
maybe also try with wget.exe
or

Code: Select all

f1=%a_scriptdir%\version.txt
UrlDownloadToFile, https://autohotkey.com/download/1.1/version.txt,%f1%
return
or this

Code: Select all

f1:="https://autohotkey.com/download/1.1/version.txt"
whr := ComObjCreate("WinHttp.WinHttpRequest.5.1")
whr.Open("GET",F1, true)
whr.Send()
; Using 'true' above and the call below allows the script to remain responsive.
whr.WaitForResponse()
version := whr.ResponseText
MsgBox % version
return
run as admin

Code: Select all

  If ( not A_IsAdmin and not TaskExists )  {
	CLine       := ( A_IsCompiled ? A_ScriptFullpath  : """"  A_AhkPath """ """ A_ScriptFullpath """" )
    Run *RunAs %CLine%, %A_ScriptDir%, UseErrorLevel
	OutputDebug % "AHK| RunAsAdmin ErrorLevel is: " ErrorLevel ", A_LastError is: " A_LastError
	if (ErrorLevel != "ERROR")
		ExitApp
   }
   
UrlDownloadToFile, https://autohotkey.com/download/1.1/version.txt, C:\AutoHotkey Latest Version.txt
return
Last edited by garry on 21 Jul 2018, 10:30, edited 1 time in total.
User avatar
JoeWinograd
Posts: 2198
Joined: 10 Feb 2014, 20:00
Location: U.S. Central Time Zone

Re: UrlDownloadToFile does nothing

21 Jul 2018, 10:06

My guess is that it's a permission error trying to write into the root of C. Try this:

Code: Select all

UrlDownloadToFile, https://autohotkey.com/download/1.1/version.txt, C:\temp\AutoHotkey Latest Version.txt
Of course, make sure that C:\temp\ exists and that you have write permission to it. The code above works perfectly here on W7 and W10. Regards, Joe

Edit: Oops...there were no other posts when I answered, but when I hit Submit, several appeared. Sorry for the dup.
garry
Posts: 3763
Joined: 22 Dec 2013, 12:50

Re: UrlDownloadToFile does nothing

21 Jul 2018, 10:11

@JoeWinograd
@gregster
thank you for comments and examples

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: No registered users and 292 guests