WindowsProcessMBS CreateProcessWithLogonW

  1. 5 months ago

    I posted this on the NUG list but might get more response here.

    I am trying to launch an application from within a Xojo app using WindowsProcessMBS (code below). It is important that I use this function as it calls the Windows CreateProcessWithLogonW and I need to authenticate as this is being developed as a Windows service.
    In testing with a console app all works well if I don’t try to authenticate, but when I include credentials, the LastErrorMessage returns "The parameter is incorrect".
    I have reviewed the Microsoft documentation for CreateProcessWithLogonW:

    https://docs.microsoft.com/de-de/windows/desktop/api/winbase/nf-winbase-createprocesswithlogonw

    and tried leaving the domain null and passing the username in UPN format (user@domain). I have also tried entering the domain and username separately. I still get the parameter error.
    Has anyone successfully used this function and any sample code to share?

    Code:
    dim w as new WindowsProcessMBS
    dim a as Integer
    dim AppPathStr, AppName as string

    AppPathStr="C:\Windows\system32"
    AppName="Notepad.exe"

    w.domain="domain"
    w.UserName="user"
    w.Password="password"
    w.CurrentDirectory=AppPathStr
    w.ApplicationName = AppPathStr + "\" + AppName

    if not w.run then
    print "Launch Error: "+w.LastErrorMessage
    Return
    end if

or Sign Up to reply!