Forum for iCal4OL, Print4OL and ICS4OL

Exchange of experiences / Erfahrungsaustausch / Get Help

You are not logged in.

Announcement

iCal4OL Version 2.9.15 is now available with support for the new Gmail-Contact Browser-Interface (see here). Please update..

#1 2009-03-30 13:50:26

Roland
Administrator
Registered: 2007-11-25
Posts: 484

Vista UAC and Visual Basic 6 - Process Elevation

Hello

My primary goal was:
I have an ActiveX.dll, which I wanted to call from a VB6 project, getting the elevation prompt for Standard Users for "Highest" or "requireAdministrator"..

There seems to be a way with ActiveX .exe:
http://www.xtremevbtalk.com/showthread.php?t=281431
http://www.xtremevbtalk.com/archive/ind … 89099.html

Well, I did not succeed with a DLL - the restriction is clearly, that DLL are running in the same thread as the calling program (which can't elevate itself)!
Here some code, how to use ActiveX .exe - perhaps you can convert your DLL to an ActiveX .exe and call it:

Code:

Set m_obj= CreateObject("Elevation:Highest!new:Test2.Test")
Set m_obj= CreateObject("Elevation:Administrator!new:{76D3822A-DE66-5338-934E-5F0868BE2CBA}")


Standard *.exe or *.bat are easy to elevate by assembly manifest files (trustinfo) or by calling Shellexecute with "runas" verb..

Code:

Private Declare Function ShellExecute Lib "Shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long

Private Sub runas(ByVal hwnd As Long, ByVal x As String, ByVal c As String)
    Dim APIReturnCode As Long
    APIReturnCode = ShellExecute(hwnd, "runas", x, c, vbNull, 0)  ' SW_HIDE=0
    If APIReturnCode < 33 Then MsgBox "(Access denied.. " & Format$(APIReturnCode) & ")", vbCritical + vbOKOnly, TITEL
End Sub



For special tasks, like copying files under C:\Program Files\, my "practical solution" is using NSIS (Nullsoft Installer) exe packages, which I call by ShellExecute (using in nsis "RequestExecutionLevel admin", "SilentInstall silent" and $EXEDIR)

For Vista Task Scheduler (V2), I'm using schtasks.exe with ShellExecute, too.

Here some interesting links:
http://www.vbforums.com/showthread.php?t=558385
http://technet.microsoft.com/en-us/maga … ation.aspx
.NET http://www.codeproject.com/KB/vista-sec … vator.aspx (http://www.tweak-uac.com/home/)
http://huddledmasses.org/vista-setuid-h … prompting/

Cheers
Roland

Offline

 

Board footer

Powered by PunBB
© Copyright 2002–2005 Rickard Andersson