The question is self-explanatory. It would be great if the code was one line long (something to do with "Process.Start("...")
"?). I researched the web but only found old examples and such ones that do not work (at least for me). I want to use this in my class library, to run Git commands (if that helps?).
相关问题
- 'System.Threading.ThreadAbortException' in
- how to use special characters like '<'
- C# to VB - How do I convert this anonymous method
- Does specifying the encoding in javac yield the sa
- Scaling image for printing
相关文章
- 在vscode如何用code runner打开独立的控制台窗口,以及设置好调试模式时窗口的编码?
- vb.net 关于xps文件操作问题
- Checking for DBNull throws a StrongTypingException
- Using the typical get set properties in C#… with p
- Load a .NET assembly from the application's re
- C# equivalent of VB DLL function declaration (Inte
- What other neat tricks does the SpecialNameAttribu
- Command line escaping single quote for PowerShell
You Can try This To Run Command Then
cmd
ExitsYou Can try This To Run The Command And Let
cmd
Wait For More CommandsThis works as well
You could try this method:
call, for example, in this way:
EDIT: For the multiple command on one line the key are the & | && and || command connectors
I was inspired by Steve's answer but thought I'd add a bit of flare to it. I like to do the work up front of writing extension methods so later I have less work to do calling the method.
For example with the modified version of Steve's answer below, instead of making this call...
MyUtilities.RunCommandCom("DIR", "/W", true)
I can actually just type out the command and call it from my strings like this...
Directly in code.
Call "CD %APPDATA% & TREE".RunCMD()
OR
From a variable.
OR
From a textbox.
textbox.text.RunCMD(WaitForProcessComplete:=True)
Extension methods will need to be placed in a Public Module and carry the
<Extension>
attribute over the sub. You will also want to addImports System.Runtime.CompilerServices
to the top of your code file.There's plenty of info on SO about Extension Methods if you need further help.
Extension Method