通用的Windows应用程序 - 启动CMD的应用 [英] Windows Universal App - Launch CMD from app

查看:122
本文介绍了通用的Windows应用程序 - 启动CMD的应用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在构建我的第一个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 ;尝试打开运行框( Win + R ),然后键入:

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 (Win+R) and typing:

shutdown /r /t 60

您会看到Windows警告系统将在60秒(当然, shutdown / a 将中止关闭)。因此,您应该只能使用 Process.Start 运行该命令。无需启动完整的命令行。

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的应用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆