You are here

How to avoid writing to the local drive C

5 posts / 0 new
Last post
Stefano900909
Offline
Last seen: 3 years 9 months ago
Joined: 2021-02-10 15:32
How to avoid writing to the local drive C

I would like to make sure that the program never writes to local disk folders such as C:\Users\USERNAME\AppData\Local\NAMEAPP.
I tried with

[DirectoriesMove]
Local-App-Data = C:\Users\USERNAME\AppData\Local\NAMEAPP

but while the program is running the path is written temporarily which I would like to avoid.

I think you need to redirect folders but I don't know if this is possible.

Thank you and good evening.

Stephen

John T. Haller
John T. Haller's picture
Offline
Last seen: 4 hours 21 min ago
AdminDeveloperModeratorTranslator
Joined: 2005-11-28 22:21
App Itself

It's up to the app itself. If the app doesn't support redirecting that (something like -settings:X:\PathToSettings on the command line) then you have to do it this way. The only way around it would be virtualization, which we don't do.

Sometimes, the impossible can become possible, if you're awesome!

Andhika24kd
Offline
Last seen: 2 months 5 days ago
Joined: 2018-06-28 07:13
Depends on how the app is written

For example, app that's written using Electron usually has parameter to override data directory, i.e., --user-data-dir=DATA_DIRECTORY. Some apps also check if a specific environment variable exist, such as QBT_PROFILE for qBittorrent and VSCODE_APPDATA for Visual Studio Code. Others also check for local file or folder existance, such as portable_mode.txt for OBS Studio, portable.dat for CCleaner, portable folder for VLC, and many more.

If the app doesn't provide native portable mode then there's nothing much to do other than using portable launcher like PAL. However there is a dirty trick by altering USERPROFILE, APPDATA, and LOCALAPPDATA environment variable to the path of your choosing, this is not recommended as it also affects every subprocesses launched by that app (possible corrupting other launched app). You can also contact the app maintainer if the project is open-source and simply wait until it's being implemented (less pain and probably the best way).

EDIT: Symlink and junction is also possible but currently can't be done using PAL (without adding custom code), also requires administrator privileges which is impossible for normal user to gain access to. Probably not working on non-NT filesystem (FAT, FAT32, etc).

AnonymousCreeper1722
Offline
Last seen: 3 years 5 months ago
Joined: 2021-02-14 06:00
Sorry!

Hello. I'm really sorry to wake up this old thread. But, this is the only thing I could find which could be of any you to me. You said >"However there is a dirty trick by altering USERPROFILE,APPDATA, and LOCALAPPDATA environment variable to the path of your choosing" and I would like to know how to do that using a batch file in windows. I'm really struggling with simple stuff, please help me(I'm NEW). This is just for my knowledge. Thanks!

Creeper1722

Andhika24kd
Offline
Last seen: 2 months 5 days ago
Joined: 2018-06-28 07:13
Set something like this at your own risk
@echo off
pushd "%~dp0"
set "USERPROFILE=YourPath"
set "APPDATA=YourPath\AppData\Roaming"
set "LOCALAPPDATA=YourPath\AppData\Local"
start "" "YourProgram.exe"
exit /B

Some apps use other methods to detect environment variables, so it may not work. Also do not skip USERPROFILE if you want to emulate APPDATA and LOCALAPPDATA path.

Batch file is more useful for setting PATH since NSIS has max string length limitation.

Log in or register to post comments