0

I have an old VB6 application that I need to maintain.

Within the app functionality is a call to CreateProcessWithLogonW which does not work when run on Windows 10 (but runs fine on Windows 7).

The error code I'm receiving via a call to Err.LastDllError is error code 740 which I think relates to "The requested operation requires elevation." UAC is disabled on the Win 10 machine which I'm running this on so I'm unsure what the issue is here??

Would anyone have any experience with this?? Any help is greatly appreciated!

What's really confusing me is the fact that it runs on Win7 without any problems at all.

Code sample is below:

Here is the function declaration:

Private Declare Function CreateProcessWithLogon Lib "Advapi32" Alias "CreateProcessWithLogonW" ( _
    ByVal UserName As Long, _
    ByVal domain As Long, _
    ByVal Password As Long, _
    ByVal dwLogonFlags As Long, _
    ByVal ApplicationName As Long, _
    ByVal strCommandLine As Long, _
    ByVal dwCreationFlags As Long, _
    ByVal lpEnvironment As Long, _
    ByVal strCurrentDirectory As Long, _
    ByRef lpStartupInfo As STARTUPINFO, _
    ByRef lppiProcessInfo As PROCESS_INFORMATION) As Long

An here is the function call

CreateProcessWithLogon(StrPtr(UserName), StrPtr(domain), StrPtr(Password), _
                                LOGON_WITH_PROFILE, StrPtr(ApplicationName), StrPtr(strCommandLine), _
                                CREATE_DEFAULT_ERROR_MODE Or CREATE_NEW_CONSOLE Or CREATE_NEW_PROCESS_GROUP, _
                                ByVal 0&, StrPtr(strCurrentDirectory), suiStartUpInfo, piProcessInfo)
P_Fitz
  • 819
  • 9
  • 16
  • 1
    Did you checked this? [Completely disable UAC in Windows 10](http://superuser.com/questions/1013702/completely-disable-uac-in-windows-10) – deblocker Jan 14 '17 at 09:00
  • 1
    Yeah - I think you're right about the UAC not being completely disabled. Even though the alert slider is all the way down I think UAC could still be affected the process launch. I've implemented a C# work around of sorts that may suffice. Thanks for your help! – P_Fitz Jan 15 '17 at 16:04
  • @P_Fitz what was your C# workaround? – vee Jan 12 '18 at 22:00
  • @nessa I followed this blog post post https://blogs.msdn.microsoft.com/alejacma/2007/12/20/how-to-call-createprocesswithlogonw-createprocessasuser-in-net/ to launch an elevated commad prompt to call a batch file whcih did the work which I need to do. Hope this helps! – P_Fitz Jan 15 '18 at 09:00

0 Answers0