VB.NET / VB - 将变量传递给Startinfo.Arguments

时间:2010-11-30 00:09:17

标签: vb.net string variables

我正在尝试在进程的StartInfo.Arguments中使用字符串变量,但无法找出正确的语法。

 Dim pquery As New Process
    Dim User As String = "test"
    pquery.StartInfo.UseShellExecute = False
    pquery.StartInfo.CreateNoWindow = True
    pquery.StartInfo.FileName = "cmd"
    pquery.StartInfo.Arguments = "/c dsquery.exe * -filter ""(&(objectClass=user)(!(objectClass=computer)(mail=***string variable should go here***)))"" | dsget user -samid"
    pquery.StartInfo.RedirectStandardOutput = True
    pquery.StartInfo.RedirectStandardError = True
    pquery.Start()

1 个答案:

答案 0 :(得分:0)

您可以使用String.Format()

将您的作业更改为pquery.StartInfo.Arguments,如下所示:

pquery.StartInfo.Arguments = String.Format("/c dsquery.exe * -filter ""(&(objectClass=user)(!(objectClass=computer)(mail={0})))"" | dsget user -samid", User)