Link to home
Start Free TrialLog in
Avatar of shawn857
shawn857

asked on

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

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
Avatar of shawn857
shawn857

ASKER

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
ASKER CERTIFIED SOLUTION
Avatar of JurajUQU
JurajUQU

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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
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
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
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.
"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
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
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