WilliamasKumeliukas

FileCopy from network share PROBLEM!

9 posts in this topic

#1 ·  Posted (edited)

the following code is working perfect only on my own computer but not on any others computers from same network... why?

(All computers can manually login to network share and drag n drop offices)

#include <file.au3>

$sRemoteName = "\\SRV\DATA\Offices"
_WinNet_UseConnection(0, "srv", $sRemoteName, "Username", "Password", 1,8)
$d = "C:\"
_FileCopy($sRemoteName, $d)

Func _FileCopy($sRemoteName, $d)
    Local $FOF_RESPOND_YES = 16
    Local $FOF_SIMPLEPROGRESS = 256
    $oShell = ObjCreate("shell.application")
    $oShell.namespace($d).CopyHere($sRemoteName,$FOF_SIMPLEPROGRESS)
EndFunc   ;==>_FileCopy

Func _cw($s)
    ConsoleWrite($s & @CRLF)
EndFunc
Edited by AutomateLover

Share this post


Link to post
Share on other sites



Where is it failing? You have zero error checking in your script. At the very least you should:

  • Add Opt(TrayIconDebug, 1) to the top of your script to see if it is hanging on a particular line of code.
  • Check for failure at the _WinNet_UseConnection statement
  • Check to ensure you enter your function successfully
  • Check to ensure you create your object successfully
  • Check for success or failure on your copy

"It doesn't work" doesn't help us to help you. If you narrow it down to where the script is failing, resolution will be a lot easier (you may even figure it out on your own). ;)


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

Where is it failing? You have zero error checking in your script. At the very least you should:

  • Add Opt(TrayIconDebug, 1) to the top of your script to see if it is hanging on a particular line of code.
  • Check for failure at the _WinNet_UseConnection statement
  • Check to ensure you enter your function successfully
  • Check to ensure you create your object successfully
  • Check for success or failure on your copy

"It doesn't work" doesn't help us to help you. If you narrow it down to where the script is failing, resolution will be a lot easier (you may even figure it out on your own). ;)

 

Sorry if I did not been precise but like I said, the script has no problem on doing what I want unless I use it on another computer with the same access privileges as my own computer to connect to network share. I'm just wondering what could cause this to be possible?

reply me whats your point about this

(I'll try OptTrayIconDebug,1)

Share this post


Link to post
Share on other sites

If you do not understand "the point" about error checking, you're going to be one frustrated programmer...


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

If you do not understand "the point" about error checking, you're going to be one frustrated programmer...

I fully understand the error checking, but as far I know at the moment, when an error occur, the script is shutted down which isn't what I see, I can call this function non stop trough IPC "inter process communications" its like it would only do consolewrite("my phrase advising me which function is starting") (the consolewrite is from the script with filecopy function to use it like Rem in cmd language)

by the way, Opt("TrayIconDebug",1) doesn't work with compiled scripts or else i don't know what I missunderstanded.

Regards

Share this post


Link to post
Share on other sites

Every builtin AutoIt function and (nearly) every UDF function tells you when an error occurred. You need to test after every function in your script and display a MsgBox or something else when an error occurred.

Example:

_WinNet_UseConnection(0, "srv", $sRemoteName, "Username", "Password", 1,8)
If @error Then Exit MsgBox(0, "Error", "Error occurred when calling _WinNet_UseConnection. @error = " & @error)

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - 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

#7 ·  Posted (edited)

 

Every builtin AutoIt function and (nearly) every UDF function tells you when an error occurred. You need to test after every function in your script and display a MsgBox or something else when an error occurred.

Example:

_WinNet_UseConnection(0, "srv", $sRemoteName, "Username", "Password", 1,8)
If @error Then Exit MsgBox(0, "Error", "Error occurred when calling _WinNet_UseConnection. @error = " & @error)

I tried and nothing happened.

No copy and no msgbox.

so there is no errors.

I guess I should make a video to show what really doing.

Edited by AutomateLover

Share this post


Link to post
Share on other sites

That's just an example. You need to do this for every function call in your script.

For each function you need to have a look at the help file and check how the function denotes an error (by the return value or by setting @error and/or @extended).


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - 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

Fixed.

_WinNet_UseConnection() seems to be the problem.

I took my local autoit folder to open my script.au3 on another computer and It did like I tough = does nothing, instantly skip to my EndSwitch line.

I've use an alternative and worked well.

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