13 Replies - 7285 Views - Last Post: 22 June 2012 - 12:03 PM Rate Topic: -----

#1 Asscotte  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 35
  • View blog
  • Posts: 610
  • Joined: 08-February 09

How to trigger the UAC in vista

Post icon  Posted 26 April 2009 - 08:26 AM

does anyone know the actual code to put into the my.settings file for this? or something like that I saw it in a post now I cant find it again 0_o .
Is This A Good Question/Topic? 0
  • +

Replies To: How to trigger the UAC in vista

#2 AdamSpeight2008  Icon User is offline

  • MrCupOfT
  • member icon


Reputation: 1949
  • View blog
  • Posts: 8,672
  • Joined: 29-May 08

Re: How to trigger the UAC in vista

Posted 26 April 2009 - 08:30 AM

What do you mean by trigger the UAC?
Was This Post Helpful? 0
  • +
  • -

#3 Asscotte  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 35
  • View blog
  • Posts: 610
  • Joined: 08-February 09

Re: How to trigger the UAC in vista

Posted 26 April 2009 - 08:37 AM

View PostAdamSpeight2008, on 26 Apr, 2009 - 07:30 AM, said:

What do you mean by trigger the UAC?

erm like when my app needs to edit the registry trigger the UAC to give my app permissions to do this
Was This Post Helpful? 0
  • +
  • -

#4 AdamSpeight2008  Icon User is offline

  • MrCupOfT
  • member icon


Reputation: 1949
  • View blog
  • Posts: 8,672
  • Joined: 29-May 08

Re: How to trigger the UAC in vista

Posted 26 April 2009 - 08:59 AM

You don't trigger it, the protection system in vista triggers it. (The registry is one of those protected places)
Even an Administrator User group has to give permission. Only one it doesn't ask, with UAC on, is the System Administrator (Administrator).


Get used to UAC it in Windows 7. In 64bit Window Vista & 7 UAC is not there, as Microsoft believe that if you're developing for a 64bit OS then you should be able to follow the guidelines.
If you don't want it appear change your program to follow the rules: See the document on VB.net resources page.

Stop thinking that VISTA Administrator = XP Administrator. (There not the same.)

The ultimate aim for the Vista Developer is develop your application/program to run under Limited User group status right, not Administrator group rights.
Set one up on your development system run your application under conditions, you'll be surprised by what breaks. (Even Microsoft applications broke.)
Was This Post Helpful? 0
  • +
  • -

#5 Asscotte  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 35
  • View blog
  • Posts: 610
  • Joined: 08-February 09

Re: How to trigger the UAC in vista

Posted 26 April 2009 - 09:19 AM

View PostAdamSpeight2008, on 26 Apr, 2009 - 07:59 AM, said:

The ultimate aim for the Vista Developer is develop your application/program to run under Limited User group status right, not Administrator group rights.
Set one up on your development system run your application under conditions, you'll be surprised by what breaks. (Even Microsoft applications broke.)



1. I dont have windows 7 so cant test that environment
2. this app is designed specificly for Administrators

the reason is, is that when I excicute the code it always says that I dont have permission to edit the registry event though I blantently do :)
Was This Post Helpful? 0
  • +
  • -

#6 AdamSpeight2008  Icon User is offline

  • MrCupOfT
  • member icon


Reputation: 1949
  • View blog
  • Posts: 8,672
  • Joined: 29-May 08

Re: How to trigger the UAC in vista

Posted 26 April 2009 - 09:51 AM

View PostAsscotte, on 26 Apr, 2009 - 03:19 PM, said:

View PostAdamSpeight2008, on 26 Apr, 2009 - 07:59 AM, said:

The ultimate aim for the Vista Developer is develop your application/program to run under Limited User group status right, not Administrator group rights.
Set one up on your development system run your application under conditions, you'll be surprised by what breaks. (Even Microsoft applications broke.)

1. I dont have windows 7 so cant test that environment

View PostAsscotte, on 26 Apr, 2009 - 03:19 PM, said:

2. this app is designed specificly for Administrators

the reason is, is that when I excicute the code it always says that I dont have permission to edit the registry event though I blantently do :)

1. Re-Read the text you quoted. (Hint: I made it Red & Bold)
2. Did you understand what i wrote.
With UAC turned on only the System Administrator is not prompted, not Administrators.
That depends on where in the registry you want to edit.
Was This Post Helpful? 0
  • +
  • -

#7 Aurel300  Icon User is offline

  • D.I.C Head

Reputation: 13
  • View blog
  • Posts: 230
  • Joined: 10-November 07

Re: How to trigger the UAC in vista

Posted 26 April 2009 - 01:05 PM

Sure, but how installers do it?
They are exceptionally allowed to change the register?
I am using XP though...
Was This Post Helpful? 0
  • +
  • -

#8 AdamSpeight2008  Icon User is offline

  • MrCupOfT
  • member icon


Reputation: 1949
  • View blog
  • Posts: 8,672
  • Joined: 29-May 08

Re: How to trigger the UAC in vista

Posted 26 April 2009 - 01:57 PM

Installers are prompted.

Generally speaking Limit Users wouldn't be Installing the software, but if they did it prompts an Administrator's password.
Was This Post Helpful? 0
  • +
  • -

#9 Guest_GertMenkel*


Reputation:

Re: How to trigger the UAC in vista

Posted 11 May 2010 - 09:09 AM

If you use Visual Studio 2008, you should try going to My Project -> Application -> View UAC Settings.
If you edit some values in there, the user will be asked for a admin password every time the application is launched.
Was This Post Helpful? 0

#10 vbnet9  Icon User is offline

  • D.I.C Regular

Reputation: 12
  • View blog
  • Posts: 331
  • Joined: 26-May 09

Re: How to trigger the UAC in vista

Posted 10 September 2010 - 07:20 AM

This will prompt:

Imports System.Security.Principal

Module VistaSecurity

    'Declare API
    Private Declare Ansi Function SendMessage Lib "user32.dll" Alias "SendMessageA" (ByVal hwnd As Integer, ByVal wMsg As Integer, ByVal wParam As Integer, ByVal lParam As String) As Integer
    Private Const BCM_FIRST As Int32 = &H1600
    Private Const BCM_SETSHIELD As Int32 = (BCM_FIRST + &HC)

    Public Function IsVistaOrHigher() As Boolean
        Return Environment.OSVersion.Version.Major < 6
    End Function

    ' Checks if the process is elevated
    Public Function IsAdmin() As Boolean
        Dim id As WindowsIdentity = WindowsIdentity.GetCurrent()
        Dim p As WindowsPrincipal = New WindowsPrincipal(id)
        Return p.IsInRole(WindowsBuiltInRole.Administrator)
    End Function

    ' Add a shield icon to a button
    Public Sub AddShieldToButton(ByRef b As Button)
        b.FlatStyle = FlatStyle.System
        SendMessage(b.Handle, BCM_SETSHIELD, 0, &HFFFFFFFF)
    End Sub

    ' Restart the current process with administrator credentials
    Public Sub RestartElevated()
        Dim startInfo As ProcessStartInfo = New ProcessStartInfo()
        startInfo.UseShellExecute = True
        startInfo.WorkingDirectory = Environment.CurrentDirectory
        startInfo.FileName = Application.ExecutablePath
        startInfo.Verb = "runas"
        Try
            Dim p As Process = Process.Start(startInfo)
        Catch ex As Exception
            Return 'If cancelled, do nothing
        End Try
        Application.Exit()
    End Sub

End Module

Was This Post Helpful? 1
  • +
  • -

#11 _HAWK_  Icon User is offline

  • Master(Of Foo)
  • member icon

Reputation: 956
  • View blog
  • Posts: 3,676
  • Joined: 02-July 08

Re: How to trigger the UAC in vista

Posted 10 September 2010 - 06:29 PM

Did you realize this thread was over a year old?!?! Good stuff though...
Was This Post Helpful? 0
  • +
  • -

#12 vbnet9  Icon User is offline

  • D.I.C Regular

Reputation: 12
  • View blog
  • Posts: 331
  • Joined: 26-May 09

Re: How to trigger the UAC in vista

Posted 10 September 2010 - 07:25 PM

View Posthawkvalley1, on 10 September 2010 - 07:29 PM, said:

Did you realize this thread was over a year old?!?! Good stuff though...


The post I replied to is maybe four months. Maybe they are still working on the project <wink>.
Was This Post Helpful? 0
  • +
  • -

#13 _HAWK_  Icon User is offline

  • Master(Of Foo)
  • member icon

Reputation: 956
  • View blog
  • Posts: 3,676
  • Joined: 02-July 08

Re: How to trigger the UAC in vista

Posted 10 September 2010 - 07:33 PM

They are the necromizer...
Was This Post Helpful? 0
  • +
  • -

#14 elpatron  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 22-June 12

Re: How to trigger the UAC in vista

Posted 22 June 2012 - 12:03 PM

View Postvbnet9, on 10 September 2010 - 07:20 AM, said:

This will prompt:

This was very helpful, thanks!
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1