开发者

VB.NET / VB - Passing a variable into Startinfo.Arguments

I'm trying to use a string variable in StartInfo.Arguments of a process, but can't figure out the correct syntax.

 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.RedirectStandard开发者_高级运维Output = True
    pquery.StartInfo.RedirectStandardError = True
    pquery.Start()


You can use String.Format():

Change your assignment to pquery.StartInfo.Arguments like so:

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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜