muxidi Posted April 20, 2022 Share Posted April 20, 2022 I got a problem of Windows can't find the file referred to in the temporary directory, I have tried various ways still error : windows cannot find c:\............make sure you typed the name correctly... #include <StaticConstants.au3> #include <WindowsConstants.au3> Local $urls = "https://www.ohchr.org/sites/default/files/Documents/Publications/HR-PUB-14-2.pdf" Local $urlsArray = StringSplit($urls,",",2) for $url In $urlsArray $sFile = DownloadFile($url) shellExecute($sFile) Next Func DownloadFile($sURL) Local $hDownload, $sFile $sFile = StringRegExpReplace($sURL,"^.*/","") $sDirectory = @TempDir & $sFile $hDownload = InetGet($sURL, $sDirectory, 17, 1) InetClose($hDownload) Return $sDirectory EndFunc ;==> GetURLImage Link to comment Share on other sites More sharing options...
Developers Jos Posted April 20, 2022 Developers Share Posted April 20, 2022 Moved to the appropriate forum. Moderation Team 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 More sharing options...
Developers Jos Posted April 20, 2022 Developers Share Posted April 20, 2022 (edited) You start the download in the background but do not wait for it to finish and close it right away! $hDownload = InetGet($sURL, $sDirectory, 17, 1) ... and you are also missing a backslash between the tempdir and the outputfile! Jos Edited April 20, 2022 by Jos 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 More sharing options...
muxidi Posted April 20, 2022 Author Share Posted April 20, 2022 Thank you for the answer ... Sorry I'm still confused, how is the right writing? Link to comment Share on other sites More sharing options...
Developers Jos Posted April 20, 2022 Developers Share Posted April 20, 2022 (edited) The proper syntax for InetGet() is explained in the helpfile (also check out the example 2) and this line is your second issue: $sDirectory = @TempDir & $sFile that needs to be something like: $sDirectory = @TempDir & "\" & $sFile Jos Edited April 20, 2022 by Jos 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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now