Windows Vista Forums
Vista Forums Home Join Vista Forums Tech Publications Windows 7 Forum Vista Tutorials Webcasts Tags

Welcome to Vista Forums we are your forum for Windows Vista help and discussion. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
Register at Vista forums...the world biggest Windows Vista resource Join Vista Forums Now

Go Back   Vista Forums > Vista Newsgroups > Vista security

using UAC permissions in a program

Update your Vista Drivers
Reply
 
Thread Tools Display Modes
Old 03-12-2007   #1 (permalink)
Michael Harvey
Guest


 

using UAC permissions in a program

Hi, my program doesn't seem to be recognizing UAC permissions.

The following program opens a file in the program files directory for read
write access. User account controls is turned on. This program succeeds in
opening the file for writing, although the program files directory is
supposed to be write protected. How do I make this program deny writing to
the file when UAC is turned on?


#include "stdafx.h"
#include <windef.h>
int _tmain(int argc, _TCHAR* argv[])
{
OFSTRUCT OpenBuff;
HFILE hf;
if (HFILE_ERROR == (hf = OpenFile("C:\\program files\\xyz\\abc.cfg",
&OpenBuff, OF_READWRITE)))
printf ("\nError opening config file.");
else {
printf ("\nSuccess opening config file.");
_lclose (hf);
}
getchar ();
return 0;
}



My System SpecsSystem Spec
Old 03-12-2007   #2 (permalink)
Jimmy Brush
Guest


 

Re: using UAC permissions in a program

Hello,

Your application must include a Vista-style manifest - this will inform
Windows that your application is designed for Windows Vista, and will turn
off any "compatability hacks" that it uses to make legacy applications work.

Here's some resources to help:

The Windows Vista Developer Story: Windows Vista Application Development
Requirements for User Account Control
http://msdn2.microsoft.com/en-us/library/aa905330.aspx

Designing Applications for Windows Vista
http://download.microsoft.com/downlo.../top10wave.exe


--
- JB
Microsoft MVP - Windows Shell/User

Windows Vista Support Faq
http://www.jimmah.com/vista/




My System SpecsSystem Spec
Old 03-12-2007   #3 (permalink)
Jesper
Guest


 

RE: using UAC permissions in a program

> Hi, my program doesn't seem to be recognizing UAC permissions.
>
> The following program opens a file in the program files directory for read
> write access. User account controls is turned on. This program succeeds in
> opening the file for writing, although the program files directory is
> supposed to be write protected. How do I make this program deny writing to
> the file when UAC is turned on?


Jimmy is correct, but you also need to specify in the manifest that you do
not want your program to get virtualized. Look in Program Files. That's not
where the file you opened went. Look in C:\Users\<your
username>\AppData\Local\VirtualStore\Program Files. That's where the file
went.

If you specify the requestedExecutionLevel in the manifest, virtualization
gets turned off.
My System SpecsSystem Spec
Old 03-12-2007   #4 (permalink)
Michael Harvey
Guest


 

Re: using UAC permissions in a program

"Jesper" <Jesper@discussions.microsoft.com> wrote in message
news:12B75380-C51E-4DEC-B477-42C048E92633@microsoft.com...
>> Hi, my program doesn't seem to be recognizing UAC permissions.
>>
>> The following program opens a file in the program files directory for
>> read
>> write access. User account controls is turned on. This program succeeds
>> in
>> opening the file for writing, although the program files directory is
>> supposed to be write protected. How do I make this program deny writing
>> to
>> the file when UAC is turned on?

>
> Jimmy is correct, but you also need to specify in the manifest that you do
> not want your program to get virtualized. Look in Program Files. That's
> not
> where the file you opened went. Look in C:\Users\<your
> username>\AppData\Local\VirtualStore\Program Files. That's where the file
> went.
>
> If you specify the requestedExecutionLevel in the manifest, virtualization
> gets turned off.


Thanks. Suppose I don't want to bother with a manifest and I want writes to
be seen by all other users. Where else could I put the file?


My System SpecsSystem Spec
Old 03-12-2007   #5 (permalink)
Jesper
Guest


 

Re: using UAC permissions in a program

%AllUsersProfile% if it is static settings

If it needs to be writeable by all users you need to modify the permissions
on it. Something writeable by all users may be better in %public%

"Michael Harvey" wrote:

> "Jesper" <Jesper@discussions.microsoft.com> wrote in message
> news:12B75380-C51E-4DEC-B477-42C048E92633@microsoft.com...
> >> Hi, my program doesn't seem to be recognizing UAC permissions.
> >>
> >> The following program opens a file in the program files directory for
> >> read
> >> write access. User account controls is turned on. This program succeeds
> >> in
> >> opening the file for writing, although the program files directory is
> >> supposed to be write protected. How do I make this program deny writing
> >> to
> >> the file when UAC is turned on?

> >
> > Jimmy is correct, but you also need to specify in the manifest that you do
> > not want your program to get virtualized. Look in Program Files. That's
> > not
> > where the file you opened went. Look in C:\Users\<your
> > username>\AppData\Local\VirtualStore\Program Files. That's where the file
> > went.
> >
> > If you specify the requestedExecutionLevel in the manifest, virtualization
> > gets turned off.

>
> Thanks. Suppose I don't want to bother with a manifest and I want writes to
> be seen by all other users. Where else could I put the file?
>
>
>

My System SpecsSystem Spec
Old 03-12-2007   #6 (permalink)
Michael Harvey
Guest


 

Re: using UAC permissions in a program

I'm a little concerned about using the "Public" directory as the name gives
the impression of being unsecure.

Could I access a directory like C:\MyAppData for read/write without
modifying permissions? I notice when I create the directory it gives the
necessary permissions to "Authenticated Users", but not to "Users". How
would a user by authenticated?

"Jesper" <Jesper@discussions.microsoft.com> wrote in message
news:B4C9DC6B-E7A8-415E-A466-0E912795F01D@microsoft.com...
> %AllUsersProfile% if it is static settings
>
> If it needs to be writeable by all users you need to modify the
> permissions
> on it. Something writeable by all users may be better in %public%
>
> "Michael Harvey" wrote:
>
>> "Jesper" <Jesper@discussions.microsoft.com> wrote in message
>> news:12B75380-C51E-4DEC-B477-42C048E92633@microsoft.com...
>> >> Hi, my program doesn't seem to be recognizing UAC permissions.
>> >>
>> >> The following program opens a file in the program files directory for
>> >> read
>> >> write access. User account controls is turned on. This program
>> >> succeeds
>> >> in
>> >> opening the file for writing, although the program files directory is
>> >> supposed to be write protected. How do I make this program deny
>> >> writing
>> >> to
>> >> the file when UAC is turned on?
>> >
>> > Jimmy is correct, but you also need to specify in the manifest that you
>> > do
>> > not want your program to get virtualized. Look in Program Files. That's
>> > not
>> > where the file you opened went. Look in C:\Users\<your
>> > username>\AppData\Local\VirtualStore\Program Files. That's where the
>> > file
>> > went.
>> >
>> > If you specify the requestedExecutionLevel in the manifest,
>> > virtualization
>> > gets turned off.

>>
>> Thanks. Suppose I don't want to bother with a manifest and I want writes
>> to
>> be seen by all other users. Where else could I put the file?
>>
>>
>>



My System SpecsSystem Spec
Old 03-12-2007   #7 (permalink)
Jesper
Guest


 

Re: using UAC permissions in a program

> I'm a little concerned about using the "Public" directory as the name gives
> the impression of being unsecure.


Data that is read-write for multiple users IS insecure. That's pretty much
the definition of it.

> Could I access a directory like C:\MyAppData for read/write without
> modifying permissions? I notice when I create the directory it gives the
> necessary permissions to "Authenticated Users", but not to "Users". How
> would a user by authenticated?


The functional difference between Authenticated Users and Users is that
Guests are members of Users, but not Authenticated Users. As there are no
enabled Guest accounts on most systems that means that for all practical
purposes they are identical.

You should not pollute the root of the file system with application specific
data. If it is configuration data, it goes in %AllUsersProfile%. If it is
application data, it should go in either %public% (if you want users to see
it outside the program) or %AllUsersProfile% if you do not. If you put it in
the latter you will need to programmatically set an ACL on it to ensure that
the intended users get the right set of permissions.
My System SpecsSystem Spec
Reply
Update your Vista Drivers

Thread Tools
Display Modes



Similar Threads
Thread Thread Starter Forum Replies Last Post
Program permissions djmorgan Software 1 06-11-2008 06:57 PM
Program Permissions Davet102 Vista General 15 06-03-2008 10:50 AM
Program Permissions Paul Martin Vista General 1 01-16-2008 12:30 PM
Permissions to install a program Frank Vista account administration 3 11-25-2007 03:27 PM
Permissions and access for program projoe688 Vista account administration 4 07-12-2007 05:27 PM


Complimentary Industry Resources

Vista Forums has joined forces with TradePub.com to offer you a new, exciting, and entirely free professional resource. Visit http://vistax64.tradepub.com today to browse our selection of complimentary Industry magazines, white papers, webinars, podcasts, and more across 34 industry sectors. No credit cards, coupons, or promo codes required. Try it today!




Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media 2005-2008

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51