How to impersonate an account and start explorer.exe?

0

I have the following code. Which results in error The application was unable to start correctly (0xc0000142). Click OK to close the application. Can someone tell me what is wrong?

        Dim domain, username, passwordStr, remoteServerName As String
        Dim password As New Security.SecureString
        Dim command As New Process

        domain = DBc.GetControlVal(34) 'Domain Name
        username = DBc.GetControlVal(35) 'Network username
        passwordStr = ENDC.DecryptData(DBc.GetControlVal(36)) 'password
        remoteServerName = DBc.GetControlVal(37) 'Remote server Name

        Dim impersonator As New clsAliasAccount(username, passwordStr)

        For Each c As Char In passwordStr.ToCharArray
            password.AppendChar(c)
        Next


        command.StartInfo.FileName = "C:\Windows\explorer.exe"
        command.StartInfo.Arguments = "\\" & remoteServerName & "\"

        command.StartInfo.UserName = username
        command.StartInfo.Password = password
        command.StartInfo.Domain = domain
        command.StartInfo.Verb = "open"
        command.StartInfo.UseShellExecute = False

        impersonator.BeginImpersonation()
        command.Start()
        impersonator.EndImpersonation()
vb.net
impersonation
windows-explorer
asked on Stack Overflow Feb 17, 2014 by JKV • edited Feb 20, 2014 by Kara

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0