问题描述
我正在构建我的第一个Win 10应用程序(在Visual C#),我有一个快速的问题。 (我是一个Java / Android家伙)
I'm building my first Win 10 app (in Visual C#) and I had a quick question. (I'm a Java/ Android guy)
我想能够从我的应用程序运行cmd行程序。这将是一个桌面应用程序,我需要有能力关闭,重新启动,锁定和中止从应用程序重新启动。我知道我可以使用'关闭'cmd,但如何启动它?
I want to be able to run cmd line programs from my app. This will be a desktop app and I need to have the ability to shutdown, restart, lock, and abort a restart from the app. I know I can use the 'Shutdown' cmd, but how can I launch it?
谢谢!
推荐答案
命令行是一个可以在没有命令行的情况下运行的程序。例如, shutdown
;尝试打开运行框( + ),然后键入:
Any program you can run from the command line is a program you can run without the command line. For example, shutdown
; try opening the Run box (+) and typing:
shutdown /r /t 60
您会看到Windows警告系统将在60秒(当然, shutdown / a
将中止关闭)。因此,您应该只能使用运行该命令。无需启动完整的命令行。
You'll see that Windows warns the system will be rebooting in 60 seconds (of course, shutdown /a
will abort the shutdown). So, you should just be able to use Process.Start
to run the command. No need to launch a full command line.
这篇关于通用的Windows应用程序 - 启动CMD的应用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!