使用vb.net

时间:2019-07-17 13:16:39

标签: vb.net command-prompt

我正在尝试使用vb.net作为管理员使用命令提示符,并通过在默认cmd.exe文件中使用runas来打开它。然后,我想使用vb.net通过新打开的命令提示符窗口(作为域管理员)运行命令。我该怎么做?

这是我正在使用的方法:

Public Sub runCmd(ByVal pass As String, ByVal command As String, ByVal arguments As String, ByVal permanent As Boolean)
    Dim p As Process = New Process()
    Dim pi As ProcessStartInfo = New ProcessStartInfo()
    pi.Arguments = " "+ If(permanent = True, "/K", "/C") + " " + command + " " + arguments
    pi.FileName = "cmd.exe"
    p.StartInfo = pi
    p.Start()
End Sub

这是打开cmd的电话:

runCmd(strPass, "runas", "/user:<domain>\" + strUser + " cmd", False)

1 个答案:

答案 0 :(得分:0)

您需要将df <- data.frame(date = seq.Date(from =as.Date("01/01/1998", "%d/%m/%Y"), to=as.Date("01/01/2000", "%d/%m/%Y"), by="day"), value = sample(seq(5), 731, replace = TRUE)) library(dplyr) library(lubridate) df %>% mutate(month = month(date), year = year(date)) %>% group_by(month, year) %>% summarise(total = sum(value)) 的{​​{1}}属性设置为Verb

StartInfo

然后您像这样调用函数:

"runas"