Hi,
We have a bot which runs in unattended mode. One step in the bot is to create a folder, move the files to this folder, and continue the further process on the files moved to this folder.
This works fine when the bot is run in attended mode or during debugging, but when the same process is run in unattended, the files do not move to the folder created by the same bot at the beginning of the process. The attended and unattended testing is done on the same machine.
What could be the issue?
Thank you,
Shreya
@Shreya_Gandhi,
Is there any error or message you are getting? Also whatās the folder path you are using?
Are you running attended and un attedned from the same machine user combination?
Thank you for quick response, @ashokkarale.
We are creating a new folder at runtime in project folder, moving the files/copying the files in this newly created folder for further processing. There is no error.
The bot is running absolutely fine in attended mode, but it is failing in unattended mode. We were troubleshooting and we found, the files do not get moved or copied to this new folder created during runtime and hence the further processing does not happen.
Shreya
Thank you for the response, @sharazkm32.
Yes. We are running on the same machine with same user credentials.
Shreya
@Shreya_Gandhi,
Got it!
Any error message you are getting?
Hi @Shreya_Gandhi,
So in unattended mode, bot is able to create folders but after that it doesnāt move any files in those folders, right?
If this is the case, you can do below few things:
- have a check enabled before moving files to the folder which checks if folder exists? If yes then only proceed to move the files in there.
- also print the folder path before moving that will help you determine which path is getting picked up during processing. Sometimes, a little space even can create the failure.
- also are you creating fresh folders everytime? If not folder would already be there and there can be the chance that the files you are trying to move re already there. So enabling a check on if the files you are trying to move already exists or not? Then accordingly configure its then and else sections would also help.
These above points would help in better error handling around folder creation and moving files.
Hope this helps.
Regards
Sonali
@ashokkarale
no error message is being displayed.
@sonaliaggarwal47
Thank you for your response.
Point 1 & 2 are already added to the code. The folder is getting created fine and the bot is picking the correct path. The bot works absolutely fine in attended, it just does not move the files to this folder in unattended run. The bot creates new folder at the beginning and tries to move the files to this folder. At the end of the process, the bot deletes the folder before ending execution. Hence its new folder created during each run of the bot.
Shreya
Hi @Shreya_Gandhi,
What happens when files are not moved? Does the processing stop right away? Are you able to trace through logs where the control is flowing after failure in moving files?
Is any error message you can see in orchestrator logs?
Are you using re-framework? What state of the framework you have included this logic into?
Regards
Sonali
Hi @Shreya_Gandhi ,
If the UiPath āMove Fileā activity isnāt working as expected, you can try an alternative method by invoking VB.NET code using the āInvoke Codeā activity. Hereās a sample code snippet that moves files from one folder to another:
' Ensure the destination folder exists
If Not System.IO.Directory.Exists(destinationFolder) Then
System.IO.Directory.CreateDirectory(destinationFolder)
End If
' Get all files in the source folder
Dim files As String() = System.IO.Directory.GetFiles(sourceFolder)
' Loop through each file and move it to the destination folder
For Each filePath As String In files
Dim fileName As String = System.IO.Path.GetFileName(filePath)
Dim destinationPath As String = System.IO.Path.Combine(destinationFolder, fileName)
System.IO.File.Move(filePath, destinationPath)
Next
Add the required arguments:
sourceFolder
(Direction: In, Type: String): Path to the folder containing files.
destinationFolder
(Direction: In, Type: String): Path to the target folder.
Thanks,
Vinit Mhatre
1 Like
Can you try using a different folder path like āDocumentsā instead of āproject folderā and check if it works, sometimes working within at runtime in project folder does not work properly.
Thank you for the response, Vinit.
I was looking at the windows level/windows security level configurations which might be causing this issue. The bot is already in production and was running fine until the previous scheduled run on January 1. If I do not find any solutions with Windows setups, We will have to make code changes and during that time I can try your solution.
Shreya
1 Like