greichert Posted October 18, 2018 Share Posted October 18, 2018 I am new to autoit and am trying to get a zipped file on my computer to download to a remote server. Is this possible with the filecopy() function? What is this best way to achieve this? Link to comment Share on other sites More sharing options...
jdelaney Posted October 18, 2018 Share Posted October 18, 2018 (edited) Filecopy to the unc path if you have permissions on your current user account to that server. If not, map a drive, and then copy to that drive mapping. DriveMapAdd Edited October 18, 2018 by jdelaney IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window. Link to comment Share on other sites More sharing options...
greichert Posted October 19, 2018 Author Share Posted October 19, 2018 16 hours ago, jdelaney said: Filecopy to the unc path if you have permissions on your current user account to that server. If not, map a drive, and then copy to that drive mapping. DriveMapAdd $user = InputBox("Security Check", "Enter your USERID.", "") $password = InputBox("Security Check", "Enter your password.", "", "*") Local $domain = "xxxxxx.com" DriveMapDel("j:") DriveMapAdd("j:", "\\xxxxxxxx\xxx\xxxxxx", 0, $domain & "\" & $user, $password) FileCopy ( "C:\Users\user\Desktop\test.zip", "J:\Users\user\Desktop" [, flag = 0] ) I am getting the following error on the "FileCopy()" function: Error: Subscript used on non-accessible variable. What am I doing wrong? Link to comment Share on other sites More sharing options...
Developers Jos Posted October 19, 2018 Developers Share Posted October 19, 2018 You need to remove those [] from that last line as they are only in the helpfile to indicate an optional parameter, and specify just a value for the Flag or use the default 0. 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...
greichert Posted October 19, 2018 Author Share Posted October 19, 2018 1 minute ago, Jos said: You need to remove those [] from that last line as they are only in the helpfile to indicate an optional parameter, and specify just a value for the Flag or use the default 0. Jos Thanks for the help. dumb mistake on my part. I removed it and added a "0". I am not getting an error anymore but I am not seeing the file being copied over. Link to comment Share on other sites More sharing options...
AdamUL Posted October 19, 2018 Share Posted October 19, 2018 You do not have any error checking your DriveMapAdd and FileCopy. Here's snippet for you to work with. expandcollapse popup#include <WinAPIDlg.au3> Global $sLocalPath = "C:\Users\user\Desktop\test.zip" Global $sShare = "\\PC-NAME\c$" Global $sSharePath = $sShare & "\Users\user\Desktop\" Global $sDomain = "xxxxxx.com" Global $sMappedDrive = "" Global $sMsg = "" Global $iMsgBoxAnswer = 0 Global $aUser[2] = ["", ""] While True $aUser = _WinAPI_ShellUserAuthenticationDlgEx($sShare & " Share", "Enter your username and password for access.", $aUser[0], $aUser[1]) If @error Then Exit If StringLeft($aUser[0], 3) <> $sDomain & "\" Then $aUser[0] = $sDomain & "\" & $aUser[0] $sMappedDrive = DriveMapAdd("*", $sShare, 0, $aUser[0], $aUser[1]) Switch @error Case 0 $aUser = 0 ExitLoop Case 2 $sMsg = "Access to the remote share was denied." Case 3 $sMsg = "The device is already assigned." Case 6 $sMsg = "Invalid password." Case Else $sMsg = "Error accessing remote share." EndSwitch $iMsgBoxAnswer = MsgBox($MB_YESNO + $MB_ICONERROR, "SHARE ACCESS ERROR" , $sMsg & @CRLF & @CRLF & "Would you like to try to connect again?") Select Case $iMsgBoxAnswer = $IDYES Case $iMsgBoxAnswer = $IDNO Exit EndSelect $aUser[1] = "" WEnd If Not FileCopy($sLocalPath, $sSharePath, $FC_OVERWRITE) Then Exit MsgBox($MB_ICONERROR, "ERROR!", "Error copying file.") DriveMapDel($sMappedDrive) Adam FrancescoDiMuro 1 Link to comment Share on other sites More sharing options...
Juvigy Posted October 22, 2018 Share Posted October 22, 2018 Try without the mapping and using UNC like: Keep in mind that you may not have permissions to do it - have you tried to do it manually? FileCopy ( "C:\Users\user\Desktop\test.zip", "\\xxxxxxxx\xxx\xxxxxx\Users\user\Desktop",0) 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