Sign in to follow this  
Tertsi

My app cannot write files anywhere on Windows 10

Recommended Posts

My application, once installed in the program files directory does not seem to be able to write files anywhere on Windows 10. (And maybe other Windows versions).
Not to C:\ProgramData\MyfoldercreatedbyNSIS_installer
Not to my documents\MyfoldercreatedbyNSIS_installer
Not to User's APPData.
Not to the program's folder (in program files), that's understandable.
Nowhere!

I need it to be able to create files and write to them.

If i move the application to somewhere else than the program files folder it works just fine and can write anywhere.

I am using the computer as an administrator but I have not set the program to run on admin privileges because I need it to run without them.

I am coding in C++, Visual Studio 2015.

Any solutions? Or is the only solution to force the players to install it outside the program files folder or run it with admin privileges?

Share this post


Link to post
Share on other sites
Could be some kind of anti-virus blocking you...? It's odd that it depends on the location of the application.

Have you debugged it while it's installed to see what the error is when it fails?

Is your program 32-bit or 64-bit, and is it in the corresponding Program Files folder? (I'm not sure if that actually matters or not, but worth a shot)

Does your program have problems running if you put it into a different folder that has a space in its name? Edited by Nypyren

Share this post


Link to post
Share on other sites

The locations you listed have in common that they're either read-only or in a folder created in NSIS.

 

Look at the access rights of the folders created by NSIS in your User folder. Is it restricted in reading or writing? There may be an error in your NSIS script that makes it create folders that require admin rights, and therefore your app can't write in them.

 

Program Files and Program Data should be read-only so even the NSIS created folders should be read-only. (They're the equivalent of /usr on Mac/Linux.)

Share this post


Link to post
Share on other sites

Thanks for the replies.

 

It seems the files get created but not written to.

I use NSIS to set full access to all users. and here is what windows 10 security details says when I check the created folder's details:

$MyCurrentUsername full access

Users group (all users) full access

administrators full access

system full access

(nothing else)

 

The program is 32 bit and is in the program files x86 folder.

"Does your program have problems running if you put it into a different folder that has a space in its name? " no.

Share this post


Link to post
Share on other sites

So, have you actually checked the error code (GetLastError) after a create/write fails? This would be a real good indication on what exactly the issue is.

 

You might think it's an issue with access rights and it could be a wrong path or similar.

Edited by Endurion

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this