View Full Version : Move an entire folder to another
LiquidIce
10-10-2014, 04:18 AM
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.
linder
10-10-2014, 04:46 AM
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
LiquidIce
10-10-2014, 05:34 AM
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,
linder
10-10-2014, 06:44 AM
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
linder
10-10-2014, 06:49 AM
By the way, here is another interesting and related reading:
http://www.lindersoft.com/forums/showthread.php?t=44128
Friedrich
linder
10-10-2014, 07:02 AM
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
LiquidIce
10-15-2014, 04:29 AM
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.
linder
10-15-2014, 04:49 AM
Hi Alejandro,
Just let me know if you need help.
Friedrich
LiquidIce
10-15-2014, 05:34 AM
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.
linder
10-15-2014, 06:09 AM
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
linder
10-15-2014, 06:25 AM
Assigned a variable to get System Info(%PROFILE%)
Quick note: you have to use Get System Info(Expand Environment Variable) for "USERPROFILE" and NOT Get System Info(Expand Environment Variable) for "%PROFILE%".
Friedrich
LiquidIce
10-15-2014, 09:18 AM
Friedrich,
I tried the message box when I was doing the first experiments and the output is the correct one, it gives me C:\Users\TheUserNameHere\.
I cannot rename it because what I want to do is move the existing directory to the Documents directory where google drive will be syncing. If i just rename it, i cannot control google drive and tell it to sync that renamed folder. I don't know if I'm explaining myself...
Ok, i'll try the USERPROFILE variable.
Alejandro.
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.