以下是流程调用的顺序;
服务调用流程A(这会导致流程A在本地系统帐户下运行)。
进程使用CreateProcessWithLogonW API在不同用户帐户(非管理员用户)下启动进程B(作为不同用户的登录凭据可用)。
进程B执行一些涉及调用另一个进程的活动。
直到第2步一切正常。流程B在给定的用户帐户下启动,但流程B无法执行任务,如执行批处理文件或使用CreateProcess API启动另一个流程。
以下是调用进程B的代码;
Dim si As STARTUPINFO
Dim pi As PROCESS_INFORMATION
Dim wUser As String
Dim wDomain As String
Dim wPassword As String
Dim wCommandLine As String
Dim wCurrentDir As String
Dim wApplicaiotnName
Dim Result As Long
si.cb = Len(si)
si.lpDesktop = "WinSta0\Default"
Result = CreateProcessWithLogonW(wUser, wDomain, wPassword, _LOGON_WITH_PROFILE,
wApplicaiotnName, "", _CREATE_UNICODE_ENVIRONMENT, 0&, wCurrentDir, si, pi)
以下代码B中使用的代码执行批处理文件;
Dim proc As PROCESS_INFORMATION
Dim start As STARTUPINFO
Dim ret As Long
Dim lpId As Long
Dim llReturn As Long
Dim RetVal As Long
With start
.cb = Len(start)
.lpDesktop = "WinSta0\Default"
If Not IsMissing(WindowStyle) Then
.dwFlags = STARTF_USESHOWWINDOW
.wShowWindow = WindowStyle
End If
End With
ret& = CreateProcessA(0&, pathName, 0&, 0&, 1&, _
NORMAL_PRIORITY_CLASS, 0&, 0&, start, proc)