+ Reply to Thread
Page 1 of 2 12 LastLast
Results 1 to 10 of 12

Thread: Move an entire folder to another

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1

    Default Move an entire folder to another

    Hello Friedrich,

    I have been trying to move a folder with its content located in the %USERPROFILE%/ to %USERPROFILE%/Documents.

    For example: a folder in the %USERPROFILE% called Test, I want it moved to the User's documents folder. This is what I did in the script editor:

    Move Folder Tree "%%USERPROFILE%%/Test to "%%USERPROFILE%%/Documents" [Permanent]

    This isn't working, do you have any idea what could be causing it not to work?
    I have read the help document but it only explains how it works.

    Regards,

    Alejandro.

  2. #2
    Join Date
    Mar 2004
    Posts
    4,307

    Default Re: Move an entire folder to another

    Alejandro,

    What is your "%%USERPROFILE%%" item? This is NOT a valid runtime variable.

    And please note that you should never ever do per-user actions from an elevated (per-machine context) running application. This is not possible (by Windows design) and will not work.

    Friedrich

  3. #3

    Default Re: Move an entire folder to another

    Friedrich,

    %USERPROFILE% is a runtime variable that takes you to the current user's home directory: C:\Users\USERNAME\
    What do you mean never do per-user actions? Because In previous actions of the installer, I make actions in the %%USERPROFILE%%/Documents and it works because it gets the current user that is logged in and does the necessary actions in his/her home directory..

    If you say its not possible, what's an alternative to getting the current logged user's home directory in order to do things?

    Regards,

  4. #4
    Join Date
    Mar 2004
    Posts
    4,307

    Default Re: Move an entire folder to another

    Alejandro,

    So you have created your own %USERPROFILE% runtime variable and then you read the current user's home directory into that variable, correct? How do you do this? And why are you using %%USERPROFILE%% (with the double %)? %%USERPROFILE%% is NOT a SetupBuilder runtime variable.

    And what you are trying to do (accessing "per-user" data from an elevated running setup application) is a serious design issue. It is simply not allowed in Windows.

    For example: a typical corporate environment scenario. The machine has an "Alejandro" Administrator account and a "JoeUser" Standard user account. You are logged-in as "JoeUser". Your own asInvoker manifested and non-elevated running applications can access the "c:\users\JoeUser" location, no problem. But what happens when you run an application elevated (e.g. your setup.exe)? Well, then over-the-shoulder will kick in and "switches" you to c:\users\Alejandro. You do NOT have access to "c:\users\JoeUser".

    Do you see where your design issue is? By Windows development guidelines, it is not allowed.

    Friedrich

  5. #5
    Join Date
    Mar 2004
    Posts
    4,307

    Default Re: Move an entire folder to another

    By the way, here is another interesting and related reading:

    http://www.lindersoft.com/forums/showthread.php?t=44128

    Friedrich

  6. #6
    Join Date
    Mar 2004
    Posts
    4,307

    Default Re: Move an entire folder to another

    Alejandro,

    Quick info: the correct syntax to get the user's profile looks like the attached code snippet.

    WARNING: you still have a design issue. You should NOT do this. This will result in a support nightmare sooner or later (because you might access an incorrect profile).

    Friedrich
    Attached Images Attached Images  

  7. #7

    Default Re: Move an entire folder to another

    Hello Friedrich,

    I will try your previous method; getting the System info. I'm trying to find where to define the function now and i'll get back to you on the outcome.

    Alejandro.

  8. #8
    Join Date
    Mar 2004
    Posts
    4,307

    Default Re: Move an entire folder to another

    Hi Alejandro,

    Just let me know if you need help.

    Friedrich

  9. #9

    Default Re: Move an entire folder to another

    Friedrich,

    I tried the following:
    Assigned a variable to get System Info(%PROFILE%) and what I did later was "Move Folder Tree "%PROFILE%\Google Drive" to "%PROFILE%\Documents\Google Drive Backup".
    What this does is crash the installer when it has to do the move folder tree process. If I try to run the compiler RUN again, it takes very long and it crashes, so I have to go to the Task Manager and end the process manually and start again.

    Alejandro.

  10. #10
    Join Date
    Mar 2004
    Posts
    4,307

    Default Re: Move an entire folder to another

    Alejandro,

    Just for fun, display the value of "%PROFILE%\Google Drive" and "%PROFILE%\Documents\Google Drive Backup" using a "Display Message Box" command. Do you see the expected values? BTW, this is still a potential candidate for a support nightmare! You are doing a per-user operation here!

    BTW, just curious, why don't you just rename the original folder? Why do you copy all the files and subfolders?

    Friedrich

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts
  •