Forum Discussion

priyaram's avatar
priyaram
Occasional Contributor
8 years ago
Solved

'An error occurred while copying a specified file (folder)' error occurred when using aqFileSystem

We are getting ‘An error occurred while copying a file (folder)’ when trying to copy specified folder using aqFileSystem.CopyFolder(sourcelocation, targetlocation). When opening specified target location folder in windows its prompting for administrative rights. Please let us know how to add permission for the current windows user to the target folder through script.

 

Please find screenshot for the dialog prompted while opening the target folder.


  • smartpriya wrote:

     

    After launching TC with admin rights the specified folder has been copied to the target location without UAC permission.


    I think you have your answer then. You want to run TC as Admin.

     

    The program (TC in this case) is what has the UAC applied to it at runtime. The link to the TC support page I posted further up gives all the details around that. You can't alter UAC for a single command within the running program. (Again, the link further up explains this - plus, it's how UAC works.)

     

    So if you want to be able to copy files in a UAC protected area, without having to run TC as admin, you'll be in the boat I described above where you'll need to invoke a command line window, with elevated rights, and use that to do your file moves. You can validate the moves with TC once the command line stuff has done it's thing, but you're not going to be able to do it all from within TC itself without running it as admin.

     

    http://stackoverflow.com/questions/32799960/jscript-how-to-get-elevated-privileges-admin-rights

  • tristaanogre's avatar
    tristaanogre
    8 years ago

    The only other alternative is, outside of TestComplete, to apply the rights to the folder to allow users read/write access so that UAC is not invoked.  As Colin_McCrae said, this is how UAC works.  

4 Replies


  • @smartpriya wrote:
    Please let us know how to add permission for the current windows user to the target folder through script.

     

    Which scripting language?

     

    Your easiest option is probably simply to make sure TestComplete is run with Admin rights. That should carry through to the scripts when run. If you're going to try and elevate through script, it can be done, but it depends on the language you're using how you do it and you may well need to drop out to a command prompt window and do your copying using that.

     

    https://support.smartbear.com/testcomplete/docs/general-info/configuring/testing-under-admin-account.html

    • priyaram's avatar
      priyaram
      Occasional Contributor

      Hi,

       

      After launching TC with admin rights the specified folder has been copied to the target location without UAC permission.

       

      We are using JScript language.

       

      Thanks,

      Priya

      • Colin_McCrae's avatar
        Colin_McCrae
        Community Hero

        smartpriya wrote:

         

        After launching TC with admin rights the specified folder has been copied to the target location without UAC permission.


        I think you have your answer then. You want to run TC as Admin.

         

        The program (TC in this case) is what has the UAC applied to it at runtime. The link to the TC support page I posted further up gives all the details around that. You can't alter UAC for a single command within the running program. (Again, the link further up explains this - plus, it's how UAC works.)

         

        So if you want to be able to copy files in a UAC protected area, without having to run TC as admin, you'll be in the boat I described above where you'll need to invoke a command line window, with elevated rights, and use that to do your file moves. You can validate the moves with TC once the command line stuff has done it's thing, but you're not going to be able to do it all from within TC itself without running it as admin.

         

        http://stackoverflow.com/questions/32799960/jscript-how-to-get-elevated-privileges-admin-rights