Jump to content
Sign in to follow this  
poila

What methods exists for downloading files from a remote computer's harddrive?

Recommended Posts

Prior to posting this question, I have experimented with using FileExists, InetGetInfo and InetGet/InetClose functions to test downloading files into my application folder, in case if my file did not already exist.

In my case, I was able to pinpoint to a very specific web address, eg.) https://dropbox.com, etc. and then check/download the file.

Now my question is, instead of checking from a hardcoded URL, is it possible to:

1. Do a check against the IP address of a remote computer, eg.) my friend's or colleague's desktop computer

2. After checking the IP address if valid and can be connected to, access the computer's hard drive location, eg.) that machine's C:specifiedFolderspecifiedFile.txt

3. Download a copy of that file into a local computer

I did read ('?do=embed' frameborder='0' data-embedContent>>) but that was what I accomplished earlier, so now I am not sure if I were to change the method of file retrieval, what changes are necessary?

Share this post


Link to post
Share on other sites

You cannot access remote computer's files unless you both are in either local or vpn network

If you have a local or vpn connection, the easiest thing i can think of is maping the network path to a temporary drive, search for the file (or if you know where it is - use that) and then copy it to local drive in a desired location. 

EDIT: acutally it is possible, but idk who will be that stupid to expose his computer to the internet via his real IP if he have one 

EDIT2: another way is if he can run an http/ftp server and you download it from there, but for me that's stupid and insecure, but inetget should work

post some more details on what you are trying to do

Edited by JustSomeone

Share this post


Link to post
Share on other sites

I am writing a program for use internally within a local network.

Initially, the program would look for a copy of an Excel file locally and if it could not found, the program throws a generic error message; otherwise, just export data into the local Excel file.

Now, I am making changes to instead throw a File Not Found message, I experimented with fetching a copy from my testing Dropbox account into the local drive. Seems fine so far, so I am switching to getting a file from a computer within a local network instead. That's when I am looking for either a simple solution of either getting a common network path, or take authentication/security into consideration before connecting.

Share this post


Link to post
Share on other sites

Check the help file for :

DriveMapAdd

DriveMapDel

FileCopy

play around with them and you will make it. If i have time i might write an example. It should not be that hard, but depend on your skills :)

Share this post


Link to post
Share on other sites

There you go, today i'm doing everything else than what i need to do lol

NOTE: this is not tested, i have no local share to try it

#include <MsgBoxConstants.au3>
#include <FileConstants.au3>


Local $dLetter = "Z:" ; drive letter to use when mapping. NOTE: must not exist
Local $nShare = "\\computer-name-or-IP\shared\folder\" ;remote share, where the backup file can be found
Local $sFilePath = "c:\path-to-my-file\" ;local path of where the file should be
Local $sFile = "my-file.something" ;the file we are searching for on our local hard drive
Local $sUsername = "Username" ; username for the remote share
Local $sPassword = "Password" ; password for the remote share
Local $sFlag = "0" ; A combination of the following: 0 = default; 1 = Persistent mapping; 8 = Show authentication dialog if required

Example()

Func Example()
    Local $iFileExists = FileExists($sFilePath)
    If $iFileExists Then
        ConsoleWrite("The file exist" & @CRLF)
        mystuff()
        sleep(100) ; you can remove this
        Exit
    Else
        ConsoleWrite("The file does not exist" & @CRLF)
        Local $tVar = DriveMapGet($dLetter)
            If $tVar = $nShare Then
                ConsoleWrite("Drive is mapped properly" & @CRLF)
            Else
                ConsoleWrite("Drive is not mapped properly" & @CRLF)
                DriveMapDel($dLetter) ; just in case it's mapped somewhere else
                sleep(10)
                DriveMapAdd($dLetter,$nShare,$sFlag,$sUsername,$sPassword)
                    If @error = 1 Then
                        MsgBox($MB_SYSTEMMODAL, "Error","There was an error mapping the drive. Error : " & @extended,5)
                    ElseIf @error = 2 Then
                        MsgBox($MB_SYSTEMMODAL, "Error","Acces to the remote share was denied",5)
                    ElseIf @error = 3 Then
                        MsgBox($MB_SYSTEMMODAL, "Error","Device " & $dLetter & " is taken.",5)
                    ElseIf @error = 4 Then
                        MsgBox($MB_SYSTEMMODAL, "Error","Device name " & $dLetter & " is invalid.",5)
                    ElseIf @error = 5 Then
                        MsgBox($MB_SYSTEMMODAL, "Error","The remote share is invalid/unreachable.",5)
                    ElseIf @error = 6 Then
                        MsgBox($MB_SYSTEMMODAL, "Error","The password provided is invalid.",5)
                    EndIf

            EndIf
        Local $fCopy = FileCopy($dLetter & "\" & $sFile, $sFilePath & "\" & $sFile, $FC_OVERWRITE)
            If $fCopy = 1 Then
                ConsoleWrite("Copy successful" & @CRLF)
                mystuff()
                Exit
            Else
                MsgBox($MB_SYSTEMMODAL, "Error","Error copying the file : " & $sFile & "." & @CRLF,5)
            EndIf
    EndIf

Exit
EndFunc

Func mystuff() ; everything in this function will be executed only if the file exists
    sleep(100)
EndFunc

Edit this to suit your needs, and if you feel like it will work, mark this as solved, so this can help in the future if more people need it :)

EDIT: fixed small non-fatal errors

EDIT: ^%^!&@*#^!@*E&Q^@ this editing, srsly

Edited by JustSomeone

Share this post


Link to post
Share on other sites

In general it would be better from a security point of view to have the target computer upload the file either to a mapped network share, or by ftp to a webserver, at regular intervals. This can be accomplished with a fairly simple script. You can save on bandwidth if you do a CRC (or just use the modified date) and only reupload if the file has changed.

Then you can download it from there with autoit commands, wget or commandline ftp. Or, just browse to it manually.

Other advantage is that you don't need to know the computer's IP address, nor does it have to be static, since the computer 'pushes' the file to you.

Another option might be rsync which is basically a Linux app for file transfer over TCP, but various Windows ports exist, eg DeltaCopy.

Share this post


Link to post
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
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By Jahar
      I have an AutoIT script It monitors 2 websites for content that applys to me and the services that I provide. One site is : www.Freelancer.com The other: www.PeoplePerHour.com Both sites publish new jobs on their site hourly or so. My AutoIT app, will view those sites and present new jobs to me in a grid that pops up on my screen. Lately, the app has stopped showing me any jobs from PeoplePerHour.
       
      For freelancer.com,  Inetget is giving full html but for peopleperhour, now its not coming.
      Func _CheckPPH()
          Local Static $hTimer = 0
          Local Static $hDownload = 0
          Local $aTitlesandUrls = 0
          Local Static $sTempFile = ""
          If $hTimer = 0 Then $hTimer = TimerInit()
          If $hDownload = 0 Then
              $sTempFile = _WinAPI_GetTempFileName(@TempDir)
              ConsoleWrite("Checking PPH..." & @CRLF)
              ConsoleWrite(">Downloading..." & @CRLF)
      ;~         $hDownload = InetGet("http://www.peopleperhour.com/freelance-jobs", $sTempFile, $INET_FORCERELOAD, $INET_DOWNLOADBACKGROUND)
              $hDownload = InetGet("http://www.peopleperhour.com/freelance-jobs", $sTempFile, $INET_FORCERELOAD)
      ;~         Return 0
          EndIf
      ;~     Sleep(30)
      ;~     Local $isCompleted = InetGetInfo($hDownload, $INET_DOWNLOADCOMPLETE)
      ;~     Local $isError = InetGetInfo($hDownload, $INET_DOWNLOADERROR)
      ;~     Sleep(30)
      ;~     If TimerDiff($hTimer) > 3000 And $isError Then
      ;~         ConsoleWrite("!PPH Fail" & @CRLF)
      ;~         InetClose($hDownload)
      ;~         $hDownload = 0
      ;~         Return 0
      ;~     EndIf
      ;~     Sleep(30)
          Local $Show = 0
      ;~     If TimerDiff($hTimer) > 3000 And $isCompleted Then
          If $hDownload > 0 Then
              ConsoleWrite("+Downloaded..." & @CRLF)
              Local $sPPHHtml = FileRead($sTempFile)
              $aTitlesandUrls = _StringBetween($sPPHHtml, '"title">' & @LF, 'time>')
      ;~         _ArrayDisplay($aTitlesandUrls)
              Local $aPPH[0][4]
              Local $sTitle = ""
              Local $sUrl = ""
              Local $sID = ""
              Local $sDate = ""
              Local $iRet=0
              Sleep(30)
              For $i = 0 To UBound($aTitlesandUrls) - 1
                  $sTitle = _StringBetween($aTitlesandUrls[$i], '<a title="', '" class')
                  $sUrl = _StringBetween($aTitlesandUrls[$i], 'href="', '">')
                  $sDate = _GetDate($aTitlesandUrls[$i])
                  If IsArray($sTitle) And IsArray($sUrl) Then
                      $sID = _GetID($sUrl[0])
      ;~                 _ArrayAdd($aPPH, $sDate & "|" & $sTitle[0] & "|" & $sUrl[0] & "|" & $sID)
                      $iRet = _BuildPopupsPPH($sID, $sDate, "PPH: " & $sTitle[0], $sUrl[0])
                      If $iRet Then $Show+=1
                  EndIf
              Next
              Sleep(30)
      ;~         If $Show > 0 Then ShowLatestJobs()
      ;~         _ArrayDisplay($aPPH)
              FileDelete($sTempFile)
              InetClose($hDownload)
              $hDownload = 0
              $hTimer = 0
              Return $Show
          EndIf
          Sleep(30)
      EndFunc   ;==>_CheckPPH
    • By IndianSage
      Hi,
      My AutoIt script is as folllows:
      ;use for calling function add2NosA in dll ;Local $vNo1 = 33 ;Local $vNo2 = 11 ;use for calling function sortNos in dll Local $vNo1 = [11,7,9] Local $vNo2 = [1,3,2] ; _ArrayDisplay($vNo1, "vNo1 display") ; _ArrayDisplay($vNo2, "vNo2 display") ;Local $hWnd = DllOpen("E:\CV-Dell-1\autoit3\myComObj1.dll") Local $hWnd = ObjCreate("myComObj1.clsMath") if (@error) Then MsgBox (0, "Error", "Error1 = " & @error) Exit EndIf ;function call method - DllCall with function name ;Local $aRes = DllCall($hWnd, "int", "addNosA", "int", $vNo1, "int", $vNo2) ;Local $aRes = DllCall($hWnd, "Ptr", "sortNos", "Array", $vNo1, "Array", $vNo2) ;function call method - $hWnd.<function name> ;Local $aRes = $hWnd.add2NosA($vNo1, $vNo2) ; this works fine with ObjCreate Local $aRes = $hWnd.sortNos($vNo1, $vNo2) if (@error) Then MsgBox (0, "Error", "Error2 = " & @error) DllClose($hWnd) Exit EndIf ;use appropriate msgbox ;MsgBox(0,"Result", "Result = " & $vNo1[0]) MsgBox(0,"Result", "Result = " & $aRes) _ArrayDisplay($vNo1, "vNo1 display") _ArrayDisplay($aRes , "aRes display") DllClose($hWnd) My VB.Net - ClassLibrary - Dll - COM obj is as follows - has 2 functions - add2NosA and sortNos:
      <ComClass(clsMath.ClassId, clsMath.InterfaceId, clsMath.EventsId)> Public Class clsMath Public Const ClassId As String = "3A42F85E-24C8-4BAA-91B5-AE56C4683C13" Public Const InterfaceId As String = "D99D7C79-2BA7-4A33-B7BC-9B7F19FDF828" Public Const EventsId As String = "CA128AC4-580C-4112-9EAD-8D1599E3F37A" Public Sub New() MyBase.New() End Sub Public Function add2NosA(ByVal no1 As Integer, ByVal no2 As Integer) As Integer Return (no1 + no2) End Function Public Sub sortNos(ByRef no1 As Array, ByRef no2 As Array) Array.Sort(no1) no2 = no1 End Sub End Class  Over all I tried various 8 options mentioned in the attached Excel file - with only 1 combination working.
      Overall could not make Array returned capture in AutoIt script. 
      Can someone help please?
      Thanks in  advance.
      Options-Tried-Matrix-Results.xlsx
    • By IndianSage
      I have create a function in FreeBasic like below:
      Extern "Windows-MS" Type tA f1 As Integer f2 As Integer End Type Public Function _switchOrder(ByVal no1 As Integer, ByVal no2 As Integer) As tA Export Dim result As Integer Dim taa As tA taa.f1 = no2 taa.f2 = no1 Return taa End Function End Extern Caller AutoIt code is:
      #include <MsgBoxConstants.au3> Global Const $sTag_ftdi_version_info="struct; int no1a; int no2a; endstruct" Local $aRet=DllCall("Math1.dll","Ptr","_switchOrder", "Int", 10, "Int", 30) ;MsgBox (0,"",@error & "-" & $aRet[0] & "-" & $aRet[1]& "-" & $aRet[2]) Local $t_ftdi_version_info=DllStructCreate($sTag_ftdi_version_info,$aRet[0]) MsgBox (0,"msg1=",@error & "---" & $aRet[0] & "-" & $aRet[1]& "-" & $aRet[2]) ;Local $retData1 = DllStructGetData($t_ftdi_version_info,"",1) Local $retData1 = DllStructGetData($t_ftdi_version_info,"no1a") MsgBox (0,"msg2=",@error & "--" & $retData1) ;Local $retData1 = DllStructGetData($t_ftdi_version_info,"",2) Local $retData1 = DllStructGetData($t_ftdi_version_info,"no2a") MsgBox (0,"msg2=",@error & "--" & $retData1) ;ConsoleWrite(DllStructGetData($t_ftdi_version_info,"",2) & "--" & @error) ;ConsoleWrite(DllStructGetData($t_ftdi_version_info,"no2a") & @CRLF) ;ConsoleWrite(DllStructGetData($tversion_str,1) & @CRLF) Getting error 2 for DllStructGetData or it give Close Application AutoIt popup message. 
      Certainly DllCall is not returning pointer to the Structure in $aRet[0] hence issue.
      Can someone help me fix this please?
      Thanks in advance.
       
       
    • By xYuri
      This simple dllcall gives me error 5, access denied,
      Func _WinAPI_VkKeyScan($__key) _WinAPI_SetLastError(0) $res = DllCall('User32.dll', 'SHORT', 'VkKeyScan', 'CHAR', $__key) _xConsole('res: '&$res) $_LastErr = _WinAPI_GetLastError() If $_LastErr <> 0 Then _xConsole('Err: {' & $_LastErr & '}> ' & _WinAPI_GetLastErrorMessage()) Return $res EndFunc Am i doing something wrong?
      Also tried VkKeyScanA and W
      Edit:
      I want to send `:` via PostMessage() WM_KEYDOWN
    • By Skysnake
      This is relevant
      From here https://stackoverflow.com/questions/3454315/is-it-possible-to-pin-a-dll-in-memory-to-prevent-unloading
      I use several UDFs on the Forum to do various things.  Those UDFs work very well.
      Effectively the UDFs are DLL wrappers, that make it possible to access DLL functions easily without the long hard slog of DLLCall() every time.
      However, I have now run into the issue that multiple UDF DLLCalls are slow. Not mind numbingly slow, but slow enough to become noticeable with a large of repeated function calls.
      So I was wondering, is it possible to "load a DLL into memory" and leave it there for the duration of my script's lifetime, avoid repeated DLL on-disk reads with a persistent in memory DLL?
      From Microsoft
      https://docs.microsoft.com/en-us/windows/desktop/dlls/about-dynamic-link-libraries
      Looks like what I want to do is: load-time dynamic linking,
      So next question, (a) how do I do this with AutoIt (b) How would this impact on standard AutoIt type DLL calls?
       
      The point is speed.  Is there a different approach?
      Or am I barking up the wrong tree?
      Skysnake
×
×
  • Create New...