How to access %APPDATA%?

If the game is located in ProgramFiles and attempts to create a save file or folder, it'll throw an EPERM Operation Not Permitted error. It is fixed by right-clicking and running as administrator, but it'd be impractical to request all gamers to do that.


What's a way around this?


I'm thinking of simply saving everything in %APPDATA%, like XP and VX did, but how can this be done?


I guess this code would have to refer to %APPDATA% instead of the same folder as the game:

Code:
StorageManager.localFileDirectoryPath = function() {
	    var path = window.location.pathname.replace(/(\/www|)\/[^\/]*$/, '/save/');
	    if (path.match(/^\/([A-Z]\:)/)) {
	        path = path.slice(1);
	    }
	    return decodeURIComponent(path);
	};




Thanks! 🙂
Nvm, fixed it:
 


    //var path = window.location.pathname.replace(/(\/www|)\/[^\/]*$/, '/save/');
    var path = process.env.APPDATA + '/YourGame Saves/'
How do I do this with 1.5.2 of MV? The lines don't read the same way, and my deployed game will not save at all, giving me those EPERM errors.
The current lines:
Code:
StorageManager.localFileDirectoryPath = function() {
    var path = require('path');

    var base = path.dirname(process.mainModule.filename);
    return path.join(base, 'save/');

Thanks!
Necro-post notice: SimProse
I suggest you start a new thread, as the cause of your problem is clearly different from that of the OP.

Moderator note: Closing this.

Original thread: https://forums.rpgmakerweb.com/threads/how-to-access-appdata.55284/