Solved

My app can't write to its INI file in Windows 7 64-bit environment

Posted on 2014-04-08
9
1,477 Views
Last Modified: 2014-04-18
Hi guys, me again pestering you right away with another question sort of related to my last one. In the last one, we solved how/where to write my 32-bit Windows\System32 files on a 64 bit machine. I've discovered another issue on my user's 64 bit system - a very innocent .ini file (just a notepad text file) that my installation writes to the user's application installation folder cannot be written to by my app. It gives a "File Access Denied" EInOutError Delphi exception error. Everything works fine here in my 32-bit Win XP development environment, but on my user's 64 bit system (Windows 7), my app can't even do a simple write to this INI text file on his system.
   
Thanks!
   Shawn
0
Comment
Question by:shawn857
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
9 Comments
 

Author Comment

by:shawn857
ID: 39987465
Further to this guys, I was signed in remotely to my user's machine and I opened this INI file manually in Notepad then tried to save it... it wouldn't even let me do that - said "File Access Denied".

Thanks
   Shawn
0
 
LVL 5

Accepted Solution

by:
JurajUQU earned 500 total points
ID: 39987473
By default Program files folder is locked for write by users in Windows 7 up environment. I believe for data there's a hidden folder called ProgramData on C: drive or use App Data in Users folder to save it. For all use Public or only current user if each user will have their own...
0
 

Author Comment

by:shawn857
ID: 39987480
Thanks for the reply Jura, but my app isn't installed in the User's "ProgramFiles" folder.. it gets installed to its own new folder "C:\MyApp".

Thanks!
   Shawn
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 5

Expert Comment

by:JurajUQU
ID: 39987485
Not the best practice possibly but fair enough

You can use icacls command during the install to give the current user during the folder creation full access to it.

http://technet.microsoft.com/en-us/library/cc753525.aspx
0
 

Author Comment

by:shawn857
ID: 39987535
Thanks Jura, I've never used that before, can you give me a little guidance please? How can I set every file to my installation folder to "full permissions"?
   Jura, I'm using an installation software that is a little restrictive (not to mention discontinued two years ago) called "Install-Us". It will however allow me to "run a program" after my installation completes. To invoke icacls, is it enough to just specify "icacls", or is it \Windows\System32\icacls", or something like that? Also, if I issue this command during an installation on an XP system that doesn't use administrator permissions, will this command fail or generate an error? Or is there still an icacls on Windows XP?

Thanks!
    Shawn
0
 
LVL 5

Expert Comment

by:JurajUQU
ID: 39987632
XP doesn't elevate rights for a local user but can do "Run As". As an application creator you should be able to set that only members of the Administrator group can install your app which solves your problem.

Not sure of XP has icacls but it might have cacls which had been depricated on new systems such as Windows 7.

All you need to do is probe during the install what system it is and then run a command accordingly. Or run calcs first and if returns failure, then run icacls.

Practical test would be the best but unfortunately I don't have XP at hand to test it out.
0
 

Author Comment

by:shawn857
ID: 39987686
"XP doesn't elevate rights for a local user but can do "Run As". As an application creator you should be able to set that only members of the Administrator group can install your app which solves your problem."

>> Well, I signed in remotely to one of my user's computer and was on as Administrator and installed my app on his system. Still, the INI files that my app installed were not writeable  :-(


"Not sure of XP has icacls but it might have cacls which had been depricated on new systems such as Windows 7."

>> I think maybe you misunderstood - I just wanted to know IF I run icacls on XP, will it give an error? I know there is no need to run icacls on an XP system... I'm just wondering what will happen if it's invoked.


"All you need to do is probe during the install what system it is and then run a command accordingly. Or run calcs first and if returns failure, then run icacls."

>> This is what I asked in my last message, can you advise me what icacls command I need to give every file in my application's install folder "full permissions"? The syntax of that icacls statement is pretty confusing and the webpage you suggested doesn't give very good example.
   Is it really necessary to probe what the target operating system is? On any windows system that uses "Administrator", I'm going to have to issue the icacls command, no? I'm getting a little confused here....

Thanks
   Shawn
0
 

Author Comment

by:shawn857
ID: 39990744
Hi Juraj, instead of struggling along with my old discontinued install software "Install-Us", I've decided to download and try to use the free Nullsoft NSIS installer. Are you familiar with how to use that software?

Thanks!
    Shawn
0
 
LVL 5

Expert Comment

by:JurajUQU
ID: 39992776
Actually I haven't tried it myself but I'm sure there are tutorials on how to do it.

https://www.youtube.com/watch?v=Cxi2QfsnqM4

or if you need more details -> http://nsis.sourceforge.net/Docs/Chapter2.html
0

Featured Post

The Ultimate Checklist to Optimize Your Website

Websites are getting bigger and complicated by the day. Video, images, custom fonts are all great for showcasing your product/service. But the price to pay in terms of reduced page load times and ultimately, decreased sales, can lead to some difficult decisions about what to cut.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

New Windows 7 Installations take days for Windows-Updates to show up and install. This can easily be fixed. I have finally decided to write an article because this seems to get asked several times a day lately. This Article and the Links apply to…
OfficeMate Freezes on login or does not load after login credentials are input.
Windows 8 comes with a dramatically different user interface known as Metro. Notably missing from the new interface is a Start button and Start Menu. Many users do not like it, much preferring the interface of earlier versions — Windows 7, Windows X…
This Micro Tutorial will give you basic overview of the control panel section on Windows 7. It will depth in Network and Internet, Hardware and Sound, etc. This will be demonstrated using Windows 7 operating system.

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question