pandagmz吧 关注:4贴子:44
  • 1回复贴,共1

自动关机.vbs

只看楼主收藏回复

Option Explicit
On Error Resume Next
Dim input,oFSO,obat,oExe,strPath,wshshell,strName,ifok,bool
strName="定时关机"
strPath="c:\\panda_shutdown.bat"
input=MsgBox("设定关机时间请按“是”取消定时关机请按“否”" ,vbinformation+vbyesno,strName)
Set oFSO=CreateObject("Scripting.FileSystemObject")
Set wshshell=CreateObject("wscript.shell")
Set obat=oFSO.CreateTextFile(strPath,true)
If input=7 Then
  obat.WriteLine "shutdown -a"
  obat.Close
  Set oExe=wshshell.exec(strPath)
  'MsgBox"定时关机已取消",vbinformation,"定时关机"
Else 
  bool=1
  input=""
  input=InputBox("请输入时间(单位:分钟):",strName)
  If input=0 Then
    ifok=MsgBox("现在关机?",vbinformation+vbyesno,strName)
    If ifok=7 Then 
  bool=0
End If
  Else If input<0 Then
         MsgBox"时间有误!",vbinformation+vbyesno,strName
 bool=0
   End If
  End If
  If bool=1 Then
               obat.WriteLine "shutdown -s -t "&input*60
               obat.Close
               Set oExe=wshshell.exec(strPath)
 End if
  'MsgBox"定时关机已设置",vbinformation,"定时关机"
End If
  wscript.sleep 1000
  oFSO.DeleteFile(strPath)
  


1楼2008-01-22 17:07回复
    Option Explicit
    On Error Resume Next
    Dim input,oFSO,obat,oExe,strPath,wshshell,strName,ifok,bool
    strName="定点关机"
    strPath="c:\\panda_shutdown.bat"
    input=MsgBox("设定"&strName&"请按“是”取消定时关机请按“否”" ,vbinformation+vbyesno,strName)
    Set oFSO=CreateObject("Scripting.FileSystemObject")
    Set wshshell=CreateObject("wscript.shell")
    Set obat=oFSO.CreateTextFile(strPath,true)
    If input=7 Then
     obat.WriteLine "at /delete /yes"
     obat.Close
     Set oExe=wshshell.exec(strPath)
     MsgBox strName&"已取消",vbinformation,strName
    Else 
     input=InputBox("请输入时间(注意:请在英文输入法状态下输入冒号或直接将样例中的数字直接替换即可):",strName,"00:00")
     obat.WriteLine "at "&input&" /every:M,T,W,TH,F,S,SU shutdown -s -t 60"
     obat.Close
     Set oExe=wshshell.exec(strPath)
     MsgBox strName&"已设置",vbinformation,strName
    End if
     wscript.sleep 1000
     oFSO.DeleteFile(strPath)


    2楼2008-01-22 21:30
    回复