监视计算机的开机和关机时间(vb代码)

来源:百度知道 编辑:UC知道 时间:2024/05/12 18:48:36
Dim begintime
Private Sub Form_Load()
Me.Hide
begintime=Now
End Sub
Private Sub Form_Unload(Cancel As Integer)
endtime=Now
n=DateDiff(〃N〃,begintime,endtime)
Dim fso As New FileSystemObject
Dim txtfile As TextStream
Set a=App
If fso.FileExists(a.Path & 〃开机记录.txt〃) Then
Set txtfile=fso.OpenTextFile(a.Path & 〃开机记录.txt〃,ForAppending)
Else
Set txtfile=fso.OpenTextFile(a.Path & 〃开机记录.txt〃,ForWriting,True)
End If
txtfile.Write 〃开机时间〃 & begintime
txtfile.Write 〃 〃&〃关机时间〃& endtime
txtfile.Write 〃 〃&〃时间长度〃& n & 〃分钟〃
txtfile.WriteBlankLines 2
End Sub
哪里错了?能帮我修改吗?

"txtfile.Write 〃 〃&〃关机时间〃& endtime
txtfile.Write 〃 〃&〃时间长度〃& n & 〃分钟〃"
这里错了!
引号用错了!
好好看看书马上就明白了!

写个VB脚本
在gpedit.msc组策略编辑器中设上自动运行
省事多了