Vb6 Vista不允许一个.exe调用另一个.exe

Vb6 Vista不允许一个.exe调用另一个.exe,vb6,windows-vista,executable,shellexecute,Vb6,Windows Vista,Executable,Shellexecute,我有一个在Vista上运行的传统VB6可执行文件。这个可执行的shell将继承另一个传统的MFC C++执行文件。 在我们早期的Vista测试中,这个调用将显示典型的UAC消息,以便在运行第二个可执行文件之前获得用户的权限。这并不完美,但可以接受。然而,现在看来操作系统完全忽略了这个调用 如何使此调用正常工作?如果计算机上禁用了UAC,并且调用将具有所需的提升权限,则对CreateProcess的调用将失败。确保UAC已启用 此外,请遵循指导原则。如果计算机上禁用了UAC,并且调用将具有所需的提

我有一个在Vista上运行的传统VB6可执行文件。这个可执行的shell将继承另一个传统的MFC C++执行文件。 在我们早期的Vista测试中,这个调用将显示典型的UAC消息,以便在运行第二个可执行文件之前获得用户的权限。这并不完美,但可以接受。然而,现在看来操作系统完全忽略了这个调用


如何使此调用正常工作?

如果计算机上禁用了UAC,并且调用将具有所需的提升权限,则对CreateProcess的调用将失败。确保UAC已启用


此外,请遵循指导原则。

如果计算机上禁用了UAC,并且调用将具有所需的提升权限,则对CreateProcess的调用将失败。确保UAC已启用


此外,请遵循指导原则。

对问题和源代码示例也有一些很好的讨论

对问题和源代码示例也有一些很好的讨论

这在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
Private声明函数CreateProcess Lib“kernel32”别名“CreateProcessA”(ByVal lpApplicationName为字符串,ByVal lpCommandLine为字符串,lpProcessAttributes为任意,lpThreadAttributes为任意,ByVal bInheritHandles为长,ByVal dwCreationFlags为长,lpEnvironment为任意,ByVal lpCurrentDriectory为字符串,lpStartupInfo为STARTUPINFO,lpProcessInformation为进程信息)为长
私有声明函数WaitForSingleObject库“kernel32”(ByVal hHandle尽可能长,ByVal DWM尽可能长)尽可能长
私有类型进程信息
hProcess尽可能长
hThread尽可能长
dwProcessId尽可能长
dwThreadId尽可能长
端型
私有类型STARTUPINFO
只要
保留为字符串
lpDesktop作为字符串
lpTitle作为字符串
dwX尽可能长
只要
dwXSize尽可能长
尽可能长
dwXCountChars的长度为
德怀康查斯一样长
dwFillAttribute尽可能长
把旗子拖得一样长
wShowWindow作为整数
cbReserved2为整数
lpReserved2尽可能长
HST输入长度为
hst输出长度
hStdError尽可能长
端型
将进程信息作为进程信息
将StartupInformation设置为STARTUPINFO
将返回值变长
将空字符串设置为字符串
将AppPathString设置为字符串
StartupInformation.cb=Len(StartupInformation)
ReturnValue=CreateProcess(NullString、AppPathString、ByVal 0&、ByVal 0&、1&、普通_优先级_类、ByVal 0&、NullString、StartupInformation、ProcessInformation)
'
'如果需要等待exe完成
'
WaitForSingleObject(ProcessInformation.hpProcess,0)0时执行
多芬特
环

这在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
Private声明函数CreateProcess Lib“kernel32”别名“CreateProcessA”(ByVal lpApplicationName为字符串,ByVal lpCommandLine为字符串,lpProcessAttributes为任意,lpThreadAttributes为任意,ByVal bInheritHandles为长,ByVal dwCreationFlags为长,lpEnvironment为任意,ByVal lpCurrentDriectory为字符串,lpStartupInfo为STARTUPINFO,lpProcessInformation为进程信息)为长
私有声明函数WaitForSingleObject库“kernel32”(ByVal hHandle尽可能长,ByVal DWM尽可能长)尽可能长
私有类型进程信息
hProcess尽可能长
hThread尽可能长
dwProcessId尽可能长
dwThreadId尽可能长
端型
私有类型STARTUPINFO
只要
保留为字符串
lpDesktop作为字符串
lpTitle作为字符串
dwX尽可能长
只要
dwXSize尽可能长
尽可能长
dwXCountChars的长度为
德怀康查斯一样长
dwFillAttribute尽可能长
把旗子拖得一样长
wShowWindow作为整数
cbReserved2为整数
lpReserved2尽可能长
HST输入长度为
hst输出长度
hStdError尽可能长
端型
将进程信息作为进程信息
将StartupInformation设置为STARTUPINFO
将返回值变长
将空字符串设置为字符串
将AppPathString设置为字符串
StartupInformation.cb=Len(StartupInformation)
ReturnValue=CreateProcess(NullString、AppPathString、ByVal 0&、ByVal 0&、1&、普通_优先级_类、ByVal 0&、NullString、StartupInformation、ProcessInformation)
'
'如果需要等待exe完成
'
WaitForSingleObject(ProcessInformation.hpProcess,0)0时执行
多芬特
环

你能给这个问题多一些上下文吗?这两个应用程序做什么?我会提前注意到,如果你想把VB6应用程序“与”C++对话,它就不能。因为C++的运行是管理员的。没有通信。只是想让一个来运行另一个,传递几个参数。它们是B。在程序文件和应用程序文件下的文件中安装了相同的目录。你能给问题多一些上下文吗?这两个应用程序做什么?我会提前注意到,如果你想把VB6应用程序“与”C++对话,它就不能。因为C++是作为管理员运行的。没有通信。s、 只是尝试让一个运行另一个,传递几个参数。它们都安装在程序文件下的同一目录下,并访问应用程序数据下的文件。嗯…所以从另一个exe调用需要管理员权限?考虑到两个exe都不需要管理员权限才能独立运行,这似乎有点极端。谢谢您的帮助。否则为什么wUAC对话框以前是否弹出过?据我回忆,该消息类似于“应用程序1正在尝试打开应用程序2.Allow?”。这似乎不是一条管理权限UAC消息,但更像是典型的“Internet Explorer正在尝试打开Outlook.Allow?”消息。我将用ACT.Hmm再次查看。因此,从另一个用户调用一个exe需要管理员权限吗?考虑到这两种需求,这似乎有点极端