Solved

Vista privilege problem

Posted on 2008-06-26
12
545 Views
Last Modified: 2013-11-20
I have Vista privilege problem.

If I install my app ( on admin user of course ) the installation works fine. On my app, a user can choose to upgrade to pro version. The upgrading download some files and copy it to the app folder. If a user installed my app and at the end of the installtion choose to open the app and then choose to upgrade to pro, everything works fine. However, if the user closed the app, opened it again, upgrading will not work and a runtime error message will raised.  on another case, where a user can check for updateds I am checking if the user account in an admin and the answer is false.
I found a place where I can turn off UAC. After I turn off UAC everything will work fine.

My question is how do I turn off this flag in advance ?

Thanks, Udi Raz
0
Comment
Question by:UdiRaz
[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
  • 4
  • 3
  • 2
  • +1
12 Comments
 
LVL 6

Accepted Solution

by:
dnudelman earned 168 total points
ID: 21872425
Right click on the icon and click properties.
Select "run this program as Administrator"  on the properties tab on the program icon.
0
 

Author Comment

by:UdiRaz
ID: 21872442
Thanks but how do I do it programmaticly using c++ code?
0
 
LVL 19

Expert Comment

by:mrwad99
ID: 21873929
You can do this via the following command:

C:\Windows\System32\cmd.exe /k %windir%\System32\reg.exe ADD
HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Pol icies\System /v EnableLUA
/t REG_DWORD /d 0 /f

However, you will need to log off again for this to take effect.  You cannot complete the turn off without logging off.

HTH
0
Technology Partners: 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!

 

Author Comment

by:UdiRaz
ID: 21874579
thanks mrwad99, but I don't want to change the account privilage, I think it is too aggressive. Now that dnudelman showed me how to change the privilage to my app alone.
0
 
LVL 19

Expert Comment

by:mrwad99
ID: 21874617
OK then, if you are happy with just running the app with Admin privelidges, you can force this by altering your app's manifest file so it will not run unless the current user can log on as an admin BTW.
0
 

Author Comment

by:UdiRaz
ID: 21874671
Sorry, didn't understand the answer:
 What do I need to change and how do I change it?
0
 
LVL 19

Assisted Solution

by:mrwad99
mrwad99 earned 166 total points
ID: 21874716
OK.  You mentioned that the first comment posted by dnudelman,

>> Right click on the icon and click properties.
Select "run this program as Administrator"  on the properties tab on the program icon.

achieves what you are after (getting the app to run with Administrator privelidges), although it is not programmatical: you have to manually do this.

I am suggesting that instead of right clicking the applications's icon, then choosing "Run as Admin..." you can embed a manifest in the application which will prompt Vista for the admin login details on app startup; essentially the same as the manual procedure outlined above.

In order to do this, you need the something like the following as your app's manifest:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
  <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
    <security>
      <requestedPrivileges>
        <requestedExecutionLevel
          level="requireAdministrator"/>
      </requestedPrivileges>
    </security>
  </trustInfo>
</assembly>

The key line is the requestedExecutionLevel.

If I am way off target here, I appologise in advance.

0
 
LVL 19

Expert Comment

by:LordOfPorts
ID: 21875780
0
 

Author Comment

by:UdiRaz
ID: 21896790
It looks like that this document answers my question but I got lost in it.
I Think that adding a manifest is the way. so I copied the suggeted xml code to a file and added it as a manifest ( visual 2005 ) but that does not. I guess just copy is not enough. I have no understanding with xml or manifests to if the example is just a guideline I still need some help to make it work,

Thanks
0
 
LVL 19

Assisted Solution

by:LordOfPorts
LordOfPorts earned 166 total points
ID: 21912830
It is not a simple process unfortunately, try following the step-by-step guide at http://support.microsoft.com/kb/944276 

In the example manifest file change the value of the level attribute from "asInvoker" to "requireAdministrator" or "highestAvailable" depending on your needs, e.g.:

<requestedExecutionLevel level="requireAdministrator" uiAccess="false"/>
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…

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