googeling 며칠 후 나는 내 자신에게 물어 봤다고 생각했다. 나는 이런 일이 일어나려고 노력하고있다 : http://gyazo.com/5274568fcb55a0fe042936e375c0b424 show current routes는 잘 작동하고 보여달라고 부탁 한 텍스트를 보여준다.VB 2013 - route add cmd elevated
그러나 경로 날 난 당신이 여기에 주로 코드의 다른 조각을 사용해야합니다 알고 지금 당신에게 코드 :
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim cmdThread As New Threading.Thread(AddressOf CmdAutomate2)
cmdThread.Start()
End Sub
Private Sub CmdAutomate2()
Dim myprocess As New Process
Dim startInfo As New System.Diagnostics.ProcessStartInfo
startInfo.FileName = "cmd"
startInfo.RedirectStandardInput = True
startInfo.RedirectStandardOutput = True
startInfo.UseShellExecute = False
startInfo.CreateNoWindow = True
myprocess.StartInfo = startInfo
myprocess.Start()
Dim sR As System.IO.StreamReader = myprocess.StandardOutput
Dim sW As System.IO.StreamWriter = myprocess.StandardInput
sW.WriteLine("route add" & textbox1.text & " " & textbox2.text)
sW.WriteLine("exit") 'exits command prompt window
results = sR.ReadToEnd 'returns results of the command window
sW.Close()
sR.Close()
Invoke(finished)
End Sub
을 보여주지 순전히 추가 : startInfo.UseShellExecute = 진정한 대신 : 를 startInfo.UseShellExecute은 거짓
을 =하지만 나에게 (내가이 포럼에서 다른 곳에서하지 가능한 confimed 수 있음) 리디렉션에 오류
을 제공합니다 이제 출력을 보여주기 위해 다른 버튼을 가지고 있어도 신경 쓰지 않습니다. 하지만 나는 웹상에서 다른 코드 조합으로 시작하지 않아도 재 설계 할 수없는 것처럼 항상 다른 오류가 발생하는 것처럼 보일 수 없다.
나는 무엇이 여기에 없습니까?
이 관리자 (예 : UAC 고도)를 실행하고 있습니까? –
당신은 오른쪽 마우스 버튼으로 관리자 권한으로 프로그램을 실행할 수 있지만 "startInfo.Verb ="runas ""와 같은 코드로 코드를 수행하지만 명령을 입력하는 데 오류가 발생합니다. –
수 없습니다. 나는 앱을 가지고 있지 않지만 당신은 그렇게하고 있습니까? –