【发布时间】:2020-06-01 16:47:21
【问题描述】:
当计划的机器人试图在锁定的系统中运行进程时,我试图通过在 UiPath 中传递用户 ID 和密码来解锁机器
下面是我的代码
'Create a new pipe client
Using pipeClient As New System.IO.Pipes.NamedPipeClientStream(
".",
"CredentialProviderPipe",
PipeDirection.InOut,
PipeOptions.None,
System.Security.Principal.TokenImpersonationLevel.Impersonation)
'Attempt to connect to it
pipeClient.Connect(10000)
'Send credentials
Dim dom As String
If Domain = "" Then
dom = Environment.UserDomainName
Else
dom = Domain
End If
Dim ss As New StreamString(pipeClient)
ss.WriteString(String.Format("LOGON{0}{1}{0}{2}{0}{3}", vbLf, dom, Username, Password))
'Wait for reply
Using pr As New StreamReader(pipeClient, System.Text.Encoding.Unicode)
Response = pr.ReadLine()
If Response = "OK" OrElse Response = "UNKNOWN" Then Return
ErrorCode = pr.ReadLine()
ErrorMessage = pr.ReadLine()
End Using
End Using
Catch ex As TimeoutException
Response = "ERROR"
ErrorCode = "0x80131505"
ErrorMessage = ex.Message
Catch ex As Exception
Response = "ERROR"
ErrorCode = ""
ErrorMessage = ex.Message
End Try
我遇到错误 BC30002: Type StringStream is not defined。
我不知道如何解决这个问题。请帮忙
【问题讨论】:
-
您认为该类型应该来自哪里?您是否在不真正了解其功能的情况下从网络上复制代码?我搜索了那个类型,发现的信息很少。 This 看起来与您正在执行的操作相似,但未提供有关该类型的信息。基本上,与其他所有类型一样,您需要引用它声明的库并导入它所属的命名空间。如果您还不知道这些是什么,则由您自己决定。
-
据我所知,
StreamString类型仅用于读写Stream。您已经在使用StreamReader从Stream中读取数据,所以我认为您可以使用StreamWriter对其进行写入并完全取消StreamString类。