积极答复者
关于shell函数的定时关机

问题
-
设计了一个Windows form程序,里面包含有3个ComboBox,分别代表时(0~23,ComboBox2)与分(0~59,ComboBox3),ComboBox1有2项,分别为“关机”和“重新启动”。这段代码如下:
Dim timePoi As String timePoi = ComboBox2.Text & ":" & ComboBox3.Text If CheckBox1.Checked = True Then If ComboBox1.Text = "关机" Then Shell("at " & timePoi & " shutdown -s -f -t 5") Else Shell("at " & timePoi & " shutdown -r -f -t 5") End If Else If ComboBox1.Text = "关机" Then Shell("at " & timePoi & " shutdown -s -t 5") Else Shell("at " & timePoi & " shutdown -r -t 5") End If End If
为何在ComboBox2、3设置了时间运行后到了时间却没有运行效果?要如何修改?谢谢!
胡人
- 已编辑 地头蛇 2012年11月8日 16:13
答案
-
建议使用System.Diagnostics.Process.Start("shutdown", "/s /t 0 /f"),参考这个例子:http://www.codeproject.com/Articles/374194/AutoShut-my-first-program-in-Csharp.
Shanks Zen
MSDN Community Support | Feedback to us
- 已标记为答案 Youen ZenModerator 2012年11月20日 7:15
全部回复
-
建议使用System.Diagnostics.Process.Start("shutdown", "/s /t 0 /f"),参考这个例子:http://www.codeproject.com/Articles/374194/AutoShut-my-first-program-in-Csharp.
Shanks Zen
MSDN Community Support | Feedback to us
- 已标记为答案 Youen ZenModerator 2012年11月20日 7:15