Jump to content

Confused by FileMove (Rename)


Recommended Posts

  • Developers

So have you tried compiling the script as Console App? 

Either way, lets go back on topic being the filemove issue. Are you 100% sure you have the rights to rename/move and the file isn't readonly or something?

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

 ran your code @Jos and got this

>"C:\Program Files (x86)\AutoIt3\SciTE\..\autoit3.exe" /ErrorStdOut "D:\OneDrive - Company Name\test.au3"    
@@ Debug(20) : @WorkingDir & "\" & $file_array[$index] = D:\OneDrive - Company Name\test.exe_
>Error code: 0
@@ Debug(22) : $rc=1  @WorkingDir & "\" & $new_file_name = D:\OneDrive - Company Name\test.exe
>Error code: 0

using this code

#include <FileConstants.au3>
#include <MsgBoxConstants.au3>
#include <WinAPIFiles.au3>

Example()

Func Example()

Local $file_array[1] = ["test.exe_"]

For $index = 0 To (UBound($file_array) - 1)
    $new_file_name = StringTrimRight($file_array[$index], 1)
    ;~ ConsoleWrite("New File name: " & $new_file_name)

    ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : @WorkingDir & "\" & $file_array[$index] = ' & @WorkingDir & "\" & $file_array[$index] & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console
    $rc=FileMove(@WorkingDir & "\" & $file_array[$index], @WorkingDir & "\" & $new_file_name)
    ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $rc=' & $rc & '  @WorkingDir & "\" & $new_file_name = ' & @WorkingDir & "\" & $new_file_name & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console
Next
EndFunc

it's working fine for me, not to say remote would work though

Edited by Earthshine

My resources are limited. You must ask the right questions

 

Link to comment
Share on other sites

5 minutes ago, Jos said:

So have you tried compiling the script as Console App? 

Either way, lets go back on topic being the filemove issue. Are you 100% sure you have the rights to rename/move and the file isn't readonly or something?

Jos

Yes, I'm sure 

image.png.ef2e35cc02d8dea6aeff954e58bde550.png

 

Link to comment
Share on other sites

21 minutes ago, Earthshine said:

can you do it remotely from command line?

Yes I could do it... 

Also, the system is working with 3 remotes machines in parallel, but only 1 has the problem. The other 2 are renaming the files with no issues 

Link to comment
Share on other sites

Well now we know it's a configuration issue and you should be able to compare those against the other two. Now we need to decide on a tool that collects all the data we need to compare

Edited by Earthshine

My resources are limited. You must ask the right questions

 

Link to comment
Share on other sites

3 minutes ago, Earthshine said:

Well now we know it's a configuration issue and you should be able to compare those against the other two. Now we need to decide on a tool that collects all the data we need to compare

What kind of configuration could be causing this? Sorry, this is out of my depth for programming

Link to comment
Share on other sites

The only thing that is really different between the machine with problems and the others is windows defender. It is active on the machine with problems and the others do not have it active.  all 3 machines are actually clones of a 4th one that works as server

 

Link to comment
Share on other sites

  • Developers

Windows Defender has this new anti ransomware option which disallows programs to start renaming files, so that would be a good candidate for cause this type of behavior.

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

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