[VB.Net]Cmd-No black

使用Cmd不產生黑窗
  1. Public Function myCmd(ByVal myCommon As String) As String
  2.  Dim process As New System.Diagnostics.Process
  3.         process.StartInfo.FileName = "cmd.exe"
  4.         process.StartInfo.UseShellExecute = False
  5.         process.StartInfo.RedirectStandardInput = True
  6.         process.StartInfo.RedirectStandardOutput = True
  7.         process.StartInfo.RedirectStandardError = True
  8.         process.StartInfo.CreateNoWindow = True
  9.         process.Start()
  10.         process.StandardInput.WriteLine(myCommon)
  11.         process.StandardInput.WriteLine("exit")
  12.         Dim myResult As String = process.StandardOutput.ReadToEnd()
  13.         process.Close()
  14.         Return myResult
  15.     End Function
EX.
  1. myCmd("del /f /s %systemdrive%\*.dol") '清除所有 *.dol 檔案

  2. 清除所有 *.dol 檔案

留言

本月最夯

偷用電腦,怎知?事件檢視器全記錄!(開機時間、啟動項時間...)