Solved

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

Posted on 2014-04-08
9
1,250 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
  • 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
 
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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Suggested Solutions

Image capture and Deploy method is consist on two phases. In our first phase we capture the image of windows from the PC in which Windows and others softwares are already installed. In second phase we deploy the created image on new PC in which we…
I hope this helps those who have been battling the SanDisk / U3 problem for a while. For anyone that is running Windows 7 64bit and is receiving and searching the internet for the “Windows Error: Windows has allocated a drive letter to the U3 dri…
In this Micro Tutorial viewers will learn how to use Boot Corrector from Paragon Rescue Kit Free to identify and fix the boot problems of Windows 7/8/2012R2 etc. As an example is used Windows 2012R2 which lost its active partition flag (often happen…
This Micro Tutorial will teach you how to the overview of Microsoft Security Essentials. This is a free anti-virus software that guards your PC against viruses, spyware, worms, and other malicious software. This will be demonstrated using Windows…

707 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now