cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
AUhawk
Level 2

UAC headache in bootstrapper

I have a bootstrap setup.exe which successfully installs multiple msi's and configures the system. I have a custom action that launches the setup.exe from programs and features. If used as immediate execution it works fine on UAC disabled machines but does not even execute on UAC enabled ones. If I use Deferred as system execution it runs under the system account which is no good as the setup needs to run as a domain user account. My bootstrapper is signed and manifested, signing the msi also does not help. Is it possible to add a manifest to the msi? alternatively has anyone managed to elevate an msi without using a bootstrapper?
Labels (1)
0 Kudos
(2) Replies
MichaelU
Level 12 Flexeran
Level 12 Flexeran

From what you describe, you have two options: don't require elevation to launch your bootstrap, or write a custom action that uses ShellExecute or a similar API to launch the boostrap. The direct options that Windows Installer exposes use the CreateProcess API which does not allow the user interface for elevation.
0 Kudos
AUhawk
Level 2

Thanks Michael

Finally got it to work using the following VBScript in A CA. This script relaunches it's self in elevated mode. Hope this helps others 🙂


If WScript.Arguments.Length = 0 Then
Set objShell = CreateObject("Shell.Application")
objShell.ShellExecute "wscript.exe" , Chr(34) & WScript.ScriptFullName & Chr(34) & " uac", "", "runas", 1
Else
RunSetup
End If

Function RunSetup
on error resume next
Dim sPath
Dim sDir
Dim filesys
Set filesys = CreateObject("Scripting.FileSystemObject")
set objShell=CreateObject("Wscript.Shell")

sPath = objShell.CurrentDirectory & "\Setup\Setup.exe"
msgbox sDir & vbcrlf & sPath
if filesys.FileExists(sPath) then
objShell.CurrentDirectory = objShell.CurrentDirectory
'objShell.Exec sPath
If FSO.FileExists(sPath) Then
objShell.ShellExecute sPath
end if
else
sDir = GetInstallDirectoryByGUID("{052B5AC5-7EA7-0904-0000-4A02000C66F4}", "{60056885-0E39-4AD9-8902-19ED3BEBC6BE}")
sPath = GetInstallDirectoryByGUID("{052B5AC5-7EA7-0904-0000-4A02000C66F4}", "{E1894689-DFFB-4510-9FD6-B7C0BA307349}")
'msgbox sDir & vbcrlf & sPath
if sPath <> "" then
objShell.CurrentDirectory = sDir
If FSO.FileExists(sPath) Then
objShell.Exec sPath
'msgbox sPath
end if
else
objShell.CurrentDirectory = Session.Property("SOURCEDIR")
If FSO.FileExists("Setup.exe") Then
objShell.Exec "Setup.exe"
end if
end if
end if
GetInstallParams = ERROR_INSTALL_USEREXIT
End function
Function GetInstallDirectoryByGUID(sProductGUID, sComponentGUID)
On Error Resume next
Dim Installer
Dim oProduct
Dim sPath

set Installer = CreateObject("WindowsInstaller.Installer")

For Each oProduct In Installer.Products
If oProduct = sProductGUID Then
sPath = Installer.ComponentPath(oProduct, sComponentGUID)
GetInstallDirectoryByGUID = "" & sPath & ""
Exit Function
End If
Next
GetInstallDirectoryByGUID = ""
End Function


Function GetValue (Path, Key)
Dim RetValue
on error resume next
const HKEY_LOCAL_MACHINE = &H80000002
'const HKEY_CURRENT_USER = &H80000001
'const HKEY_CLASSES_ROOT = &H80000000
'const HKEY_USERS = &H80000003
'const HKEY_CURRENT_CONFIG = &H80000005
'const HKEY_DYN_DATA = &H80000006

Computer = "."
Set Reg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & Computer & "\root\default:StdRegProv")

Reg.GetStringValue HKEY_LOCAL_MACHINE, Path, Key, RetValue
RetValue = RetValue & ""
GetValue = RetValue

End Function

Function SetValue (Path, Key, Value)
On Error Resume next
Dim WSHShell, RegKey

Set WSHShell = CreateObject("WScript.Shell")

RegKey = "HKLM\" & Path & "\" & Key

WSHShell.RegWrite RegKey, Value, "REG_SZ"
End Function


Function GetINSTALLDIR
On Error Resume next
Dim sPath
Dim REGPATH
REGPATH = "SOFTWARE\SourceCode\BlackPearl\BlackPearl Studio"

sPath = GetValue (REGPATH, "InstallDir")
if sPath = "" then
sPath = "C:\Program Files\K2.net 2007"
end if
GetINSTALLDIR = sPath
end function

Function GetSUPPORTDIR
On Error Resume next
Dim sPath
Dim REGPATH
REGPATH = "SOFTWARE\SourceCode\BlackPearl\BlackPearl Studio"

sPath = GetValue (REGPATH, "SUPPORTDIR")
if sPath = "" then
sPath = Session.Property("SUPPORTDIR")
end if
GetSUPPORTDIR = sPath
end function
'
0 Kudos