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

前端 未结 2 1350
被撕碎了的回忆
被撕碎了的回忆 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: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.

提交回复
热议问题