Jump to content

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?

Link to comment
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
Link to comment
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.

Link to comment
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
Link to comment
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.

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

×
×
  • Create New...