Jump to content
Sign in to follow this  
hogfan

FileCopy to UNC path......strange issue

Recommended Posts

hogfan

Hello, I have run into a strange issue with my application written in AutoIT lately.  I was using the old Word.au3 UDF function WordDocSaveAs to save a word document to a UNC path.  I updated my code to use Water's new WordEx.au3 functions, and this resolved the previous issue I was having (a crash un-related to this issue).

With the new WordEx.au3 Word_DocSaveAs function I started to get failures saving to the UNC path I was previously saving the file to.  So I figured, maybe there was something different between the two Word UDFs.

So to work around this I just decided to save the Word document locally to the desktop first, and then use a FileCopy function to copy the file to the UNC path.  However, the FileCopy still failed as well.  So next I tried attempting the Filecopy within a For......Next Loop with a sleep of 10000 between attempts, thinking maybe their was just latency to the UNC path.

;attempt to copy Files up to 3 attempts
For $x = 1 to 3
If FileCopy($sourceFile, $destFile, 9) Then ExitLoop
Sleep(10000)
Next
 
;If the FileCopy fails more than 3 times
If $x > 3 Then
Msgbox(64, "Copy Failed!", "The copy was not able to complete successfully!")
 
Else
Msgbox(64, "Copy Complete!", "The copy completed successfully!")
EndIf
This continued to failed.  I would think that this was a permissions related issue to the UNC path, but I am able to browse to this location manually, and manually copy files over without issue.  In addition, I am able to access the UNC path directly from the Run command as well.  Any ideas as to why the filecopy function would not be able to write to the UNC path, but I obviously have permissions as I can create files manually there?   As for additional troubleshooting, I am displaying a messagebox to display my $sourceFile & $destFile variables and there are not any issues with the path names.  I have also tried putting " " around the paths but that does not seem to make a difference.  Any suggestions are appreciated as I am scratching my head on this one. 
 
-hogfan
Edited by hogfan

Share this post


Link to post
Share on other sites
water

You talk about FileCopy but use DirCopy in your script :huh:


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-01-27 - Version 1.3.3.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites
hogfan

Water -

Sorry about that.  I'm am using the example code in two different scripts.  I just copied the block of code as and example.  Copy & paste error on my part.  It should read FileCopy.  I will edit that to avoid any confusion.

-hogfan

Share this post


Link to post
Share on other sites
water

Can you post the values of $sourceFile and $destFile?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-01-27 - Version 1.3.3.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites
hogfan

The value of $destFile is:

server.domain.comshared0163LettersNew LettersCustomer Letters2013-Customer Letters (folder #2)

the value of $sourceFile is:

C:Documents & SettingsmyUsernameDesktopNew Customer Letter.doc

-hogfan

Share this post


Link to post
Share on other sites
hogfan

Also, I find it odd that FileCopy to the UNC path doesn't work, but I am able to programmatically open the share with 

ShellExecute('"' & $destFile & '"')

and once that window opens I can manually drag and drop the file there from the desktop.

-hogfan

Share this post


Link to post
Share on other sites
water

Does

DriveMapAdd("*", "\\server.domain.com\shared")
MsgBox(0, "DriveMapAdd", "@error = " & @error)

work for you?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-01-27 - Version 1.3.3.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites
BrewManNH

Is $sourcefile actually set to "C:Documents & Settings" or is it set to "C:Documents and Settings"?


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites
hogfan

@Brewman

It is actually set to "C:Documents and Settings".  I just typed in the path in my post.  Good catch though.  I've done some more digging and I'm still leaning to a possible permission related issue on the share......I found out it is a Novell share.  I just doesn't make sense that that I can shell to that path and then drag and drop a file there, but the filecopy fails.  

-hogfan

Share this post


Link to post
Share on other sites
blckpythn

Do your paths need quotes? Example:

FileCopy('"' & $source & '"', '"' & $dest & '"', 9)
Edited by blckpythn

Share this post


Link to post
Share on other sites
KaFu

Maybe give this one a try?

FileCopy("C:\Documents and Settings\myUsername\Desktop\New Customer Letter.doc", "\\?\UNC\server.domain.com\shared\0163\Letters\New Letters\Customer Letters\2013-Customer Letters (folder #2)\")

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  

×