Sign in to follow this  
Followers 0

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

6 posts in this topic

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

#2 ·  Posted (edited)

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 :




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

#5 ·  Posted (edited)

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


Func Example()
    Local $iFileExists = FileExists($sFilePath)
    If $iFileExists Then
        ConsoleWrite("The file exist" & @CRLF)
        sleep(100) ; you can remove this
        ConsoleWrite("The file does not exist" & @CRLF)
        Local $tVar = DriveMapGet($dLetter)
            If $tVar = $nShare Then
                ConsoleWrite("Drive is mapped properly" & @CRLF)
                ConsoleWrite("Drive is not mapped properly" & @CRLF)
                DriveMapDel($dLetter) ; just in case it's mapped somewhere else
                    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)

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


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

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  
Followers 0

  • Similar Content

    • Leo1906
      By Leo1906
      Hello Guys,
      once aggain I need your help on a DLL Topic
      I need to pass arguments to my function via a structure, because I am limited to only one argument that can be passed.
      But I don't think that thats so important.
      So here's my approach:
      C++ Code (just the important part):
      extern "C" { struct ParamStruct { const char* test1; const char* test2; const char* test3; int size; }; int testFunc(struct ParamStruct * params) { return params->size; } } And thats how I try to call the function using Autoit:
      Local $struct = "struct;char shapefile[128];char output[128];char filename[128];int size;endstruct" Local $tTest = DllStructCreate($struct) DllStructSetData($tTest, "test1", "Bla") DllStructSetData($tTest, "test2", "BlaBla") DllStructSetData($tTest, "test3", "BlaBlaBla") DllStructSetData($tTest, "size", 40) $dll = DLLOpen("myDLL.dll") $ret = DllCall($dll, "int:cdecl", "testFunc", "STRUCT*", DllStructGetPtr($tTest)) MsgBox(0, 0, $ret[0]) DllClose($dll) Just for testing I want the function to just return the integer value in the struct.
      But this aint working. I tested many things, but still I'm not able to get it running. I even don't know if the mistakes are in the C++ code or the Autoit code or both .. I'm not that skilled at C++ and also not that skilled at Autoit DLLCalls :-/
      I would really appreciate some help!
      Kind regards,
    • MagicSpark
      By MagicSpark
      can someone help me out with some DllCall in AU3.
      The relevant source of function and struct definition are as follows (in slightly modified form):
      typedef struct {     char    *host;     char    *key;     char    *value; } test_sender_value_t; /******************************************************************************  * Parameters: address   - [IN] server address                                *  *             port      - [IN] server port                                   *  *             source    - [IN] source IP, optional - can be NULL             *  *             values    - [IN] array of values to send                       *  *             count     - [IN] number of items in values array               *  *             result    - [OUT] the server response/error message, optional  *  *                                                                            *  * Return value: 0 - the values were sent successfully, result contains       *  *                         server response                                    *  *               -1 - an error occurred, result contains error message        *  *                                                                            *  ******************************************************************************/ TEST_API int test_sender_send_values(const char *address, unsigned short port, const char *source, const test_sender_value_t *values, int count, char **result);
      In AutoIt I use the following code to build the struct and call the dll:
      Global $struct = DllStructCreate("ptr ptrtostring1;ptr ptrtostring2;ptr ptrtostring3;") Global $string1 = DllStructCreate("char host[255];") DllStructSetData($string1, "host", "Test_Client") DllStructSetData($struct, "ptrtostring1", DllStructGetPtr($string1)) Global $string2 = DllStructCreate("char key[255];") DllStructSetData($string2, "key", "clientver") DllStructSetData($struct, "ptrtostring2", DllStructGetPtr($string2)) Global $string3 = DllStructCreate("char value[255];") DllStructSetData($string3, "value", "123456") DllStructSetData($struct, "ptrtostring3", DllStructGetPtr($string3)) Global $aCall = DllCall("C:\temp\test.dll", "int", "test_sender_send_values", _     "str", "", _     "int", 80, _     "str", "", _     "ptr", DllStructGetPtr($struct), _     "int", 1) If @error Then     ConsoleWrite("Error: " & @error & @CRLF)     exit 1 Else     ConsoleWrite("Success: " & $aCall[0] & @CRLF) EndIf
      If I ran the AU3-Script with SciTE I get the following output:
      !>12:00:00 AutoIt3.exe ended.rc:-1073741783 Can someone point me into the right direction. I must admit, that I'm very new to handling DLL-Calls and structs.
      But I've read down the forum threads and the AutoIt help.
      Thanks in advance.
    • jonson1986
      By jonson1986
      I'm trying to use InetGet function to download multiple images from a website, some pages having three images, some pages having 4 images some of them having more...
      I wrote belong codes to work with autoit and having issues when autoit find not matching url available then autoit just script stopped without any error and I just want to same all the avaialble images on the website if links are not more left then script should moves on but script just stopped...
      Here is complete scenerio
      I've so many webpages with random number of images are hosting on those pages, in below code, InetGet able to download first three files easily and when it reaches to 4th link that is missing on the webpage that's why script stopped just but I want autoit to download only those images those are links are available and rest of files needs to be skipped automatically for this page if on the next page 4th link of image avaiable then autoit script needs to download 4th one also.
      Furthermore, please help me to download files with it's original names instead of whatever name I want to same them like in InetGet I've to give some name to the file that I'm willind to download instead of original name that is available online.
      Please Help me.
      Here i my code;
      $File6 = @ScriptDir & "\images_source.txt" $txt6 = FileRead($File6) $target_source7 = _StringBetween($txt6, 'src="', '"') if Not @error Then InetGet ( $target_source7[0], @ScriptDir & '\Description\Image1.jpg'); 1st image download coz link is available InetGet ( $target_source7[1], @ScriptDir & '\Description\Image2.jpg'); 2nd image download coz link is available InetGet ( $target_source7[2], @ScriptDir & '\Description\Image3.jpg'); 3rd image download coz link is available InetGet ( $target_source7[3], @ScriptDir & '\Description\Image4.jpg'); 4th image not able to download coz link is not available and script just stopped EndIf  
    • 31290
      By 31290
      Hi Guys, 
      Since I'm able to get a Dell equipment warranty status thanks to my API key, I'm using an UDF to extract data from an XML file and get the end date. > 
      Thing is, when using InetGet, the original file is in JSON format and the UDF is not working anymore, even if I download the file with the xml extension. Therefore, and when I manually download the page with Chrome, I have a proper XML file where the UDF is working fine.
      Here's my code:
      I even tried to convert the json to xml >
      I took a look here but I don't understand anything :/
      The XML read UDF is just perfect for my needs but I'm stuck here... 
      Thanks for any help you can provide
    • likehu
      By likehu
      I have compiled a reference DLL in VS 2015 Community and this  DLL works fine with project for which it is used. There is an interface from which u can access functions in DLL.
      Developers stated that this DLL is almost universal and can be used with any language with minor changes.
      I am trying to access its function from Autoit script and got an error 3, after calling DLLCall - "function" not found in the DLL file.
      Please have a quick look, I feel I miss something in C++ library with exporting functions and I do not know what to add as I am new to C++.
      Thank you.
      Source files and script also attached.
      Here is my script.
      Local $dll = DllOpen("C:\Users\Home\Desktop\dll\user.dll") ConsoleWrite("$dll handle = " & $dll & @CRLF) ;$dll handle = 1 Local $result = DllCall($dll, "double:cdecl", "ProcessQuery", "str", "dll$mynumber") If @error > 0 Then ConsoleWrite("Error: " & @error & @CRLF) ;Error = 3 If IsArray($result) Then ConsoleWrite("Array returned!" & @CRLF & "dll$mynumber: " & result[1]) Else ConsoleWrite("$result is not array. : " & $result & @CRLF) ;$result = 0 EndIf DllClose($dll) And here is dll source. As I understand, function "ProcessQuery" exported with help of DLL_IMPLEMENTS
      //****************************************************************************** // // This file is part of the OpenHoldem project // Download page: // Forums: // Licensed under GPL v3: // //****************************************************************************** // // Purpose: Very simple user-DLL as a starting-point // // DO NOT CHANGE ANYTHING IN THIS FILE! // // This Header defines an interface // Functions and data-types must exactly match. // //****************************************************************************** #ifndef _INC_USER_H #define _INC_USER_H // Import and export directives // for use by this DLL and by OpenHoldem #ifdef USER_DLL #define DLL_IMPLEMENTS extern "C" __declspec(dllexport) #define EXE_IMPLEMENTS extern "C" __declspec(dllimport) #else #define DLL_IMPLEMENTS extern "C" __declspec(dllimport) #define EXE_IMPLEMENTS extern "C" __declspec(dllexport) #endif // Number of saved table-states // This number must not be changed, as we do a "& 0xFF" // at various places to normalize the index. const int kNumberOfHoldemStatesForDLL = 256; // SHoldemePlayer // used for sequence of 256 consequive table-states // !!!! Needs 2 more cards for Omaha, if not entirely removed struct holdem_player { char m_name[16] ; //player name if known double m_balance ; //player balance double m_currentbet ; //player current bet unsigned char m_cards[2] ; //player cards unsigned char m_name_known : 1 ; //0=no 1=yes unsigned char m_balance_known : 1 ; //0=no 1=yes unsigned char m_fillerbits : 6 ; //filler bits unsigned char m_fillerbyte ; //filler bytes }; struct holdem_state { char m_title[64] ; //table title double m_pot[10] ; //total in each pot unsigned char m_cards[5] ; //common cards unsigned char m_is_playing : 1 ; //0=sitting-out, 1=sitting-in unsigned char m_is_posting : 1 ; //0=autopost-off, 1=autopost-on unsigned char m_fillerbits : 6 ; //filler bits unsigned char m_fillerbyte ; //filler byte unsigned char m_dealer_chair ; //0-9 holdem_player m_player[10] ; //player records }; // Functions implemented and exported by the DLL, // imported by OpenHoldem DLL_IMPLEMENTS double __stdcall ProcessQuery(const char* pquery); DLL_IMPLEMENTS void __stdcall DLLOnLoad(); DLL_IMPLEMENTS void __stdcall DLLOnUnLoad(); // Functions implemented and exported by OpenHoldem, // imported by the DLL EXE_IMPLEMENTS double __stdcall GetSymbol(const char* name_of_single_symbol__not_expression); EXE_IMPLEMENTS void* __stdcall GetPrw1326(); EXE_IMPLEMENTS char* __stdcall GetHandnumber(); EXE_IMPLEMENTS void __stdcall ParseHandList(const char* name_of_list, const char* list_body); EXE_IMPLEMENTS char* __stdcall ScrapeTableMapRegion(char* p_region, int& p_returned_lengh); EXE_IMPLEMENTS void __stdcall SendChatMessage(const char *message); EXE_IMPLEMENTS void __stdcall WriteLog(char* format, ...); // Variables exported by OpenHoldem // avoiding the message-mess of WinHoldem, // no longer sending any state-messages // EXE_IMPLEMENTS extern holdem_state state[kNumberOfHoldemStatesForDLL]; EXE_IMPLEMENTS extern int state_index; #endif // _INC_USER_H  
      user.cpp    Here is dll$mynumber parameter.
      //****************************************************************************** // // This file is part of the OpenHoldem project // Download page: // Forums: // Licensed under GPL v3: // //****************************************************************************** // // Purpose: Very simple user-DLL as a starting-point // // Required OpenHoldem version: 7.7.6 // //****************************************************************************** // Needs to be defined here, before #include "user.h" // to generate proper export- and inport-definitions #define USER_DLL // #define OPT_DEMO_OUTPUT if you are a beginner // who wants to see some message-boxes with output of game-states, etc. // It is disabled upon request, // * as it is not really needed // * as some DLL-users don't have MFC (atlstr.h) installed // #undef OPT_DEMO_OUTPUT #include "user.h" #include <conio.h> #include <windows.h> #ifdef OPT_DEMO_OUTPUT #include <atlstr.h> #endif OPT_DEMO_OUTPUT // Supporting macros #define HIGH_NIBBLE(c) (((c)>>4)&0x0F) #define LOW_NIBBLE(c) ((c)&0x0F) // Card macro #define RANK(c) ( ISKNOWN(c) ? HIGH_NIBBLE(c) : 0 ) #define SUIT(c) ( ISKNOWN(c) ? LOW_NIBBLE(c) : 0 ) #define ISCARDBACK(c) ((c) == CARD_BACK) #define ISUNKNOWN(c) ((c) == CARD_UNDEFINED) #define ISNOCARD(c) ((c) == CARD_NOCARD) #define ISKNOWN(c) (!ISCARDBACK(c) && !ISUNKNOWN(c) && !ISNOCARD(c)) // ProcessQuery() // Handling the lookup of dll$symbols DLL_IMPLEMENTS double __stdcall ProcessQuery(const char* pquery) { if (pquery==NULL) return 0; if (strncmp(pquery,"dll$mynumber",13)==0) { return 12345.67; } return 0; } // OnLoad and OnUnload() // called once and at the beginning of a session // when the DLL gets loaded / unloaded // Do initilization / finalization here. DLL_IMPLEMENTS void __stdcall DLLOnLoad() { #ifdef OPT_DEMO_OUTPUT MessageBox(NULL, "event-load", "MESSAGE", MB_OK); #endif OPT_DEMO_OUTPUT } DLL_IMPLEMENTS void __stdcall DLLOnUnLoad() { #ifdef OPT_DEMO_OUTPUT MessageBox(NULL, "event-unload", "MESSAGE", MB_OK); #endif OPT_DEMO_OUTPUT } // DLL entry point // Technically required, but don't do anything here. // Initializations belong into the OnLoad() function, // where they get executed at run-time. // Doing things here at load-time is a bad idea, // as some functionalitz might not be properly initialized // (including error/handling). BOOL APIENTRY DllMain(HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) { switch (ul_reason_for_call) { case DLL_PROCESS_ATTACH: #ifdef OPT_DEMO_OUTPUT AllocConsole(); #endif OPT_DEMO_OUTPUT break; case DLL_THREAD_ATTACH: break; case DLL_THREAD_DETACH: break; case DLL_PROCESS_DETACH: #ifdef OPT_DEMO_OUTPUT FreeConsole(); #endif OPT_DEMO_OUTPUT break; } return TRUE; }