How to execute a .bat file from a C# windows form app?

前端 未结 2 1343
被撕碎了的回忆
被撕碎了的回忆 2020-12-20 12:39

What I need to do is have a C# 2005 GUI app call a .bat and several VBScript files at user\'s request. This is just a stop-gap solution until the end of the holidays and I c

相关标签:
2条回答
  • 2020-12-20 13:31

    Here is what you are looking for:

    Service hangs up at WaitForExit after calling batch file

    It's about a question as to why a service can't execute a file, but it shows all the code necessary to do so.

    0 讨论(0)
  • 2020-12-20 13:36

    For the problem you're having about the batch file asking the user if the destination is a folder or file, if you know the answer in advance, you can do as such:

    If destination is a file: echo f | [batch file path]

    If folder: echo d | [batch file path]

    It will essentially just pipe the letter after "echo" to the input of the batch file.

    0 讨论(0)
提交回复
热议问题