Prevent stuff from being written to My Documents

Prevent stuff from being written to My Documents

Discuss your problems with the latest release of the engine here. Problems with games, maps or other utilities belong in their respective forums.

Moderator: Moderators

User avatar
Jools
XTA Developer
Posts: 2816
Joined: 23 Feb 2009, 16:29

Prevent stuff from being written to My Documents

Post by Jools »

How do you disable programs from writing stuff to the My Documents folder? I've tried to denying the SYSTEM user from having write permission to that folder (not whole My Documents, but My Documents/My Games/Spring), but it can still write there. Do you know any good tricks for how to achieve this?

Do I have to also disable all Administrator users from write access to that directory? I don't care if it renders the Spring directory there orphan or whatever, I just want to stop it being written to.

I'm using win7.
abma
Spring Developer
Posts: 3798
Joined: 01 Jun 2009, 00:08

Re: Prevent stuff from being written to My Documents

Post by abma »

You have to set access rights for the user which is used to run the program. Very likely you will get crashes, etc when doing so. I suggest to either configure the programs or set a symlink.
User avatar
Jools
XTA Developer
Posts: 2816
Joined: 23 Feb 2009, 16:29

Re: Prevent stuff from being written to My Documents

Post by Jools »

Thank you, that was the solution. I post it for reference in case anyone else encounters this issue with some spring malware. Go to "My Documents" and right-click on "My Games", choose open command window here. Type the following:
mklink /D Spring NUL
That will send everything that wants to write something to the Spring folder, or try to create it, to an electronic black hole. You now have control of your computer again.
User avatar
Silentwings
Posts: 3720
Joined: 25 Oct 2008, 00:23

Re: Prevent stuff from being written to My Documents

Post by Silentwings »

http://www.techsupportalert.com/content ... -drive.htm

If you honestly think that "control of your computer" has anything to do with where your mydocs folder is then you are mad.
User avatar
Jools
XTA Developer
Posts: 2816
Joined: 23 Feb 2009, 16:29

Re: Prevent stuff from being written to My Documents

Post by Jools »

Yes, it is my decision what I want to be saved in a folder, or what things I want to be saved in My Documents (which I think is for documents) and what I want in other places. If a program doesn't respect that then I don't have control over it. I just posted one way to achieve this.

Note: if you use linux you should use /dev/null instead
User avatar
Silentwings
Posts: 3720
Joined: 25 Oct 2008, 00:23

Re: Prevent stuff from being written to My Documents

Post by Silentwings »

Also, independent of the fact that Windows offers you choice of where to put your personal folders (if you had bothered to look for it), Spring itself has "isolation mode" http://springrts.com/phpbb/viewtopic.ph ... 44#p538808.
User avatar
Jools
XTA Developer
Posts: 2816
Joined: 23 Feb 2009, 16:29

Re: Prevent stuff from being written to My Documents

Post by Jools »

This has nothing to do with windows: I obviously know about how to relocate folders on windows and the problems with them as well (it's not recommended on a setup that you must use for productive work, only for testing, because it breaks programs such as windows migration wizard).

Documents are typically different than games, and that's why I have chosen to locate My Documents on a hard drive that's optimised for speed and not for storage. Games are more close to video and media files in my opinion, I don't want to keep them under My Documents. I keep them on another hard drive. Anyway, whatever reason I have to put things where I want is none of the business of Spring, or other people. I simply want to decide myself where to put my files.

I know about isolation and portable mode. Atm I think I'm running portable mode with the write-dir defined by env-variables as well as springsettings Datadir. But all spring programs do not respect that.
User avatar
jK
Spring Developer
Posts: 2299
Joined: 28 Jun 2007, 07:30

Re: Prevent stuff from being written to My Documents

Post by jK »

User avatar
Jools
XTA Developer
Posts: 2816
Joined: 23 Feb 2009, 16:29

Re: Prevent stuff from being written to My Documents

Post by Jools »

Ah, but I can't put spring in isolation mode then because I have many locations from where I need it to read files. I need it to read files from the install directory (C:/Spring), data-dir (U:/data/spring), as well as a gitbub folder, one folder for each widget/gadget).

It currently works really well in portable mode, except fro some programs that insist to use My Documents anyway.
User avatar
Silentwings
Posts: 3720
Joined: 25 Oct 2008, 00:23

Re: Prevent stuff from being written to My Documents

Post by Silentwings »

to relocate folders on windows and the problems with them as well (it's not recommended on a setup that you must use for productive work...
Wrong, Microsoft recommends it (although I'm not advocating this as as a general principle for "things you should do"). http://windows.microsoft.com/en-gb/wind ... =windows-7.
it breaks programs such as windows migration wizard
Also wrong since (as you'd know if you'd bothered to read it) (1) it's an easily reversible operation and (2) moreover, migration wizard allows you to migrate any non-system files you like from/to anywhere you like.
Documents are typically different than games... blah blah ... to decide myself where to put my files.
Also wrong since Windows gives you the option to create your own libaries.
User avatar
Jools
XTA Developer
Posts: 2816
Joined: 23 Feb 2009, 16:29

Re: Prevent stuff from being written to My Documents

Post by Jools »

Silentwings wrote:Wrong, Microsoft recommends it (although I'm not advocating this as as a general principle for "things you should do"). http://windows.microsoft.com/en-gb/wind ... =windows-7.
Not possible for "My Games", only for the whole "My Documents". The location tab is not available for "My Games".

Also, seems it's not just spring that has issues with redirected folders:
http://steamcommunity.com/app/232750/di ... 679013000/
User avatar
Silentwings
Posts: 3720
Joined: 25 Oct 2008, 00:23

Re: Prevent stuff from being written to My Documents

Post by Silentwings »

Windows gives you the option to create your own libraries.
klapmongool
Posts: 843
Joined: 13 Aug 2007, 13:19

Re: Prevent stuff from being written to My Documents

Post by klapmongool »

Portable Mode

An all-in-one-folder setup, which allows to run Spring without installation. To do so all relevant files (binaries & basecontent) must be in a single folder, esp. spring(.exe), libunitsync.so/unitsync.dll and springsettings.cfg. Spring will then use the all-in-one-folder for writing and won’t do so anywhere else on the system, but it may open other files & directories for reading.
Both SpringLobby(packed with Spring) and Spring itself write outside of the installation directory. So this description is not correct.
Isolation Mode

Not to confuse with Portable Mode, this mode disables all automatic Data Dir scanning and limit reading & writing to a single folder. This is very usefull when games want to run separate from other Spring games.
How do I apply this? Should there be an option in the lobby to put -s behind spring.exe?
User avatar
Jools
XTA Developer
Posts: 2816
Joined: 23 Feb 2009, 16:29

Re: Prevent stuff from being written to My Documents

Post by Jools »

It works for me for most stuff. Let's say you have the following:

A - spring install directory
B - Spring Data directory (this you want writeable)
C - Additional read directory(ies)

Install spring to A. Put a springsettings.cfg in same dir with following parameter: SpringData = B

In B, you then have your main springsettings.cfg, which can have many SpringData values, like SpringData = C;D;...;Z. I'm not sure if you need to, but I also have the environment variable SPRING_WRITEDIR = B.

Now, if you install a new spring version in directory A2, all you need to copy to it is the springsettings.cfg with path to B, and your own uikeys.txt file. All rest can be kept in B (like your own widgets, maps, etc).

If a program, after all these steps taken, still writes in My Documents: I don't know how you can say it is following your control? I consider it malware. God knows what else it will do.
User avatar
Silentwings
Posts: 3720
Joined: 25 Oct 2008, 00:23

Re: Prevent stuff from being written to My Documents

Post by Silentwings »

Portable mode... Spring itself writes outside of the installation directory
If Spring itself really does so in portable mode then obviously you should make a mantis with details.
klapmongool
Posts: 843
Joined: 13 Aug 2007, 13:19

Re: Prevent stuff from being written to My Documents

Post by klapmongool »

Silentwings wrote:
Portable mode... Spring itself writes outside of the installation directory
If Spring itself really does so in portable mode then obviously you should make a mantis with details.
Apparently it already has been. Solution is some manual fix. Anyway, devs know and should (could?) act upon it (by either removing portable from download page or making it actually portable by default).

Also, I'm not gonna set up a VM with clean install to provide examples.
abma
Spring Developer
Posts: 3798
Joined: 01 Jun 2009, 00:08

Re: Prevent stuff from being written to My Documents

Post by abma »

i know users don't care what is causing it but to understand you have to distinguish between the programs that write to "My Documents": mostly lobbies and engine.

to make it really portable you have to configure both of them, if you only configure the engine most lobbies will ignore it and vice versa. springlobby for example should have a config setting for all paths since v0.189 but it can be only configured by editing the config file atm, help->system info should show all relevant paths, if some path is outside where it should be, fix the config setting.

springlobby currently also doesn't set SpringData dir automaticly, this could be done but atm i guess it would cause many trouble as some users already configured paths on their own.

still "easiest" fix is to create a symlink my games\spring -> dir you want to have it as it works with all lobbies and engines.
User avatar
Jools
XTA Developer
Posts: 2816
Joined: 23 Feb 2009, 16:29

Re: Prevent stuff from being written to My Documents

Post by Jools »

abma wrote:i know users don't care what is causing it but to understand you have to distinguish between the programs that write to "My Documents": mostly lobbies and engine.
Why can't they both use an agreed way to listen to where the user wants the stuff installed? Why not check for that env.variable for instance.
abma wrote: springlobby currently also doesn't set SpringData dir automaticly, this could be done but atm i guess it would cause many trouble as some users already configured paths on their own.
Please don't do this. The SpringData dir should be used to listen to what the user wants, not telling him what the lobby wants. I already stopped using weblobby because of this, because each time I use it I have to go back and reconfigure my SpringData dir variable to read from multiple places.
abma
Spring Developer
Posts: 3798
Joined: 01 Jun 2009, 00:08

Re: Prevent stuff from being written to My Documents

Post by abma »

Jools wrote:Please don't do this. The SpringData dir should be used to listen to what the user wants, not telling him what the lobby wants. I already stopped using weblobby because of this, because each time I use it I have to go back and reconfigure my SpringData dir variable to read from multiple places.
lobbies have to work without a spring installed. they have to decide where to place stuff, so they have to say to spring, where to write its stuff as well. it can't work the other way arround.

also using an env var is fail to set a dir imo. it doesn't allow to prepackage stuff/preconfigure it, it has to be a config setting. if lobby for example would set an env var, the var wouldn't be set if spring is run directly, without the env-var set -> fail.
User avatar
Jools
XTA Developer
Posts: 2816
Joined: 23 Feb 2009, 16:29

Re: Prevent stuff from being written to My Documents

Post by Jools »

Ok, but there are so many lobbies and only one engine. I understand those points, but why not check for the presence of an optional env.var/springData setting, and if it doesn't exist, go with default.
Post Reply

Return to “Help & Bugs”