如何模拟帐户并启动explorer.exe?

时间:2014-02-17 12:12:28

标签: vb.net impersonation windows-explorer

我有以下代码。哪个导致错误The application was unable to start correctly (0xc0000142). Click OK to close the application.有人能告诉我出了什么问题吗?

        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()

0 个答案:

没有答案