views:

606

answers:

3

I have a legacy VB6 executable that runs on Vista. This executable shells out another legacy MFC C++ executable.

In our early Vista testing, this call would display the typical UAC message to get the user's permission before running the second executable. This wasn't perfect, but acceptable. However, it now looks like this call is being completely ignored by the OS.

What can I do to make this call work?

+3  A: 

If UAC is disabled on the machine, and the call would have required elevated privileges, then the call to CreateProcess will fail. make sure UAC is enabled.

Additionally, follow the guidelines here for adding a UAC manifest to your program.

1800 INFORMATION
Hmm.. so calling one exe from another requires admin rights? That seems a little extreme, considering neither needs admin rights to run standalone. Thanks for the help.
JKueck
Why else would the UAC dialog have popped up before?
1800 INFORMATION
From what I recall, the message was something like 'App 1 is trying to open App2. Allow?'. This didn't seem to be a admin rights UAC message, but more like the typical 'Internet Explorer is trying to open Outlook. Allow?' message. I'll take another look with ACT.
JKueck
+1  A: 

There is also some good discussion of the issues and source examples here.

Jim Burger
A: 

This works well for us under Vista

Private Declare Function CreateProcess Lib "kernel32" Alias "CreateProcessA" (ByVal lpApplicationName As String, ByVal lpCommandLine As String, lpProcessAttributes As Any, lpThreadAttributes As Any, ByVal bInheritHandles As Long, ByVal dwCreationFlags As Long, lpEnvironment As Any, ByVal lpCurrentDriectory As String, lpStartupInfo As STARTUPINFO, lpProcessInformation As PROCESS_INFORMATION) As Long

Private Declare Function WaitForSingleObject Lib "kernel32" (ByVal hHandle As Long, ByVal dwMilliseconds As Long) As Long

Private Type PROCESS_INFORMATION
      hProcess As Long
      hThread As Long
      dwProcessId As Long
      dwThreadId As Long
End Type

Private Type STARTUPINFO
      cb As Long
      lpReserved As String
      lpDesktop As String
      lpTitle As String
      dwX As Long
      dwY As Long
      dwXSize As Long
      dwYSize As Long
      dwXCountChars As Long
      dwYCountChars As Long
      dwFillAttribute As Long
      dwFlags As Long
      wShowWindow As Integer
      cbReserved2 As Integer
      lpReserved2 As Long
      hStdInput As Long
      hStdOutput As Long
      hStdError As Long
End Type

    Dim ProcessInformation As PROCESS_INFORMATION
    Dim StartupInformation As STARTUPINFO
    Dim ReturnValue As Long
    Dim NullString As String
    Dim AppPathString As String

    StartupInformation.cb = Len(StartupInformation)

    ReturnValue = CreateProcess(NullString, AppPathString, ByVal 0&, ByVal 0&, 1&, NORMAL_PRIORITY_CLASS, ByVal 0&, NullString, StartupInformation, ProcessInformation)
    '
    'If you need to wait for the exe to finish
    '
    Do While WaitForSingleObject(ProcessInformation.hProcess, 0) <> 0
        DoEvents
    Loop
RS Conley
Will give this a shot!
JKueck