1

リソースにあるcmdファイルを使用してバッチファイルを実行しようとしています。私はどこにもそれらを抽出しようとはしていません。フォームのbatコマンドを編集して、持っているcmdファイルで実行したいだけです。これは可能ですか?

4

1 に答える 1

3

最初にディスクに保存せずに.cmdまたはファイルを実行する方法はありません。読んで解釈する.batためにそこになければなりません。cmd.exe最初にディスクに保存して、そこから実行する必要があります。

保存したら、System.Diagnostics.Processを使用して実行できます。リンクのVB.Netの例から:

Imports System
Imports System.Diagnostics
Imports System.ComponentModel

Namespace MyProcessSample
Class MyProcess

  Public Shared Sub Main()
    Dim myProcess As New Process()

      Try                ' Get the path that stores user documents.
        myProcess.StartInfo.UseShellExecute = False
        ' You can start any process, HelloWorld is a do-nothing example.
        myProcess.StartInfo.FileName = "C:\\HelloWorld.exe"
        myProcess.StartInfo.CreateNoWindow = True
        myProcess.Start()
        ' This code assumes the process you are starting will terminate itself. 
        ' Given that is is started without a window so you cannot terminate it 
        ' on the desktop, it must terminate itself or you can do it 
        ' programmatically from this application using the Kill method.
      Catch e As Exception
        Console.WriteLine((e.Message))
      End Try
    End Sub 'Main
  End Class
End Namespace
于 2012-04-15T07:29:24.417 に答える