Windows Universal App - Launch CMD from app

2019-07-07 01:17发布

I'm building my first Win 10 app (in Visual C#) and I had a quick question. (I'm a Java/ Android guy)

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?

Thank you!

标签: c# windows cmd
1条回答
该账号已被封号
2楼-- · 2019-07-07 02:07

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

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.

查看更多
登录 后发表回答