VB 关机代码.想让它能在各系统下运行.

来源:百度知道 编辑:UC知道 时间:2024/06/21 17:33:56
能关xp,vista,2000,及将来的windows 7.以前的系统.

你编译之后是.exe应该可以的啊

On Error GoTo err100
If mnutimeclose.Caption = "定时关机" Then
mnutimeclose.Caption = "取消定时关机"
Dim xx As Single
xx = InputBox("请输入时间,1表示一个小时、0.5表示半个小时", "关机时间/小时", 1)
If xx <= 0 Then
xx = InputBox("请重新输入时间,1表示一个小时、0.5表示半个小时", "关机时间", 1)
mnutimeclose_Click
End If
xx = xx * 3600
Shell app.path & "/shutdown.exe -s -t " & xx
Else
Shell app.path & "/shutdown.exe -a"
mnutimeclose.Caption = "定时关机"
End If
err100:
End Sub

Shell "C:\WINDOWS\system32\shutdown.exe -s -t 0"