tags:

views:

195

answers:

2

I have a windows application,sometimes in windows 7(also ultimate with administrator user) and vista to run it i need to right click and run it as administrator,I know the reason is attempt to access to system directories from my program,how i can solve this problem,is

net user administrator /active:yes
that using for enabling the real aministrator account solve the problem? if no what should i do ! Thx

A: 

The answer depends on why do you need administrator rights (i.e. what kind of application do you have).

Alexander
coz my program have a windows service to doing backup files and i want to put it in system directory
sam
i want to run it without UAC prompt
sam
MR Alexander i think the answer is really separate from the application kind,i can solve it by an alternative way,but i think it should be a simple way,coz many of softwares that want to access sys dirs and run scripts and ... have this problem
sam
@sam I'm not sure if I got what you're saying. Do you mean that you write some kind of installer application, which installs a Win32 service?
Alexander
yes a Win32 service in system directory
sam
In that case you need to add manifest with requestedExecutionLevel = requireAdministrator. Use search. For example, see these questions: http://stackoverflow.com/questions/2432329/how-do-i-deploy-applications-in-run-as-administrator-mode http://stackoverflow.com/questions/2588330/delphi-app-manifest-file-problems-under-winxp-and-win7
Alexander
+3  A: 

...that using for enabling the real aministrator account solve the problem?

What exactly is "the problem"?

If the problem is that it is inconvenient to right-click and choose "Run as administrator..." every time you need to execute the program, then you can add a manifest to the program's resources. Then the UAC prompt will appear automatically. This has been discussed in some detail in other SA questions.

Andreas Rejbrand
just it is inconvenient to right-click or appear UAC Propmt
sam
@sam, Andreas' answer is taking care of the right-click, but for the UAC prompt, if your goal is to bypass it, I strongly feel against it: it would be a security breach.
François
i think no,appear the prompt or right-click over and over again gets a little annoying,specially if ur customers can't understand english and ur program is also not in english language, so they ask you what is this this ... it's borring to do again
sam
In many cases the right answer is not doing this at all. For example, you may require admin rights, if you write in HKLM or All users. It *may* be what you need. But it also may be that you need to write to HKCU or your profile instead of global. Blindly require admin's rights is not good approach, unless you're 100% sure.
Alexander
Sam, the dialog is displayed using the OS language. If the users don't understand English, then they should have installed Windows with a non-English language. That's not a problem for you to solve, unless you are also the sysadmin.
Rob Kennedy
I think i'm in courthouse,exc i prefer to call all of my customers and talk about this problem (i'll tell them: if our program didn't work so right-click every time u want to run it,if you don't want to right-click every time,so u can create a shourtcut and to create a shourtcut u can read help) that's nice. thx sooo
sam