To jest mój kawałek kodu....(słynna piosenka :) )
If GetOS = "Vista" Or GetOS = "Win7" Then
If WScript.Arguments.length =0 Then
Set objShell = CreateObject("Shell.Application")
objShell.ShellExecute "wscript.exe", """" & _
WScript.ScriptFullName & """" & " uac","", "runas", 1
Else
LogDateTime
Set objFSO=CreateObject("Scripting.FileSystemObject")
outFile="C:\Windows\RemoveSpy_AIO.log"
Set objFile = objFSO.OpenTextFile(outFile, 8)
objFile.Write LogDateTime+" Przywracanie systemu - uruchomienie CRP.VBS" & vbCrLf
objFile.Close
CreateSRP
End If
End If
If GetOS = "Win81" Or GetOS = "Win10" Then
If WScript.Arguments.length =0 Then
Set objShell = CreateObject("Shell.Application")
objShell.ShellExecute "wscript.exe", """" & _
WScript.ScriptFullName & """" & " uac","", "runas", 1
Else
LogDateTime
Set objFSO=CreateObject("Scripting.FileSystemObject")
outFile="C:\Windows\RemoveSpy_AIO.log"
Set objFile = objFSO.OpenTextFile(outFile, 8)
objFile.Write LogDateTime+" Przywracanie systemu - uruchomienie CRP.VBS" & vbCrLf
objFile.Close
const HKEY_LOCAL_MACHINE = &H80000002
strComputer = "."
Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\default:StdRegProv")
strKeyPath = "SOFTWARE\Microsoft\Windows NT\CurrentVersion\SystemRestore"
strValueName = "SystemRestorePointCreationFrequency"
oReg.SetDWORDValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName, 0
CreateSRP
oReg.DeleteValue HKEY_LOCAL_MACHINE, strKeyPath, strValueName
End If
End If
Sub CreateSRP
curDate = Year(Date) & "-" & Right(String(2, "0") & Month(Date),2) & "-" & Day(Date) & "_" & Time
InputMy = InputBox (" Wpisz w³asn¹ nazwê dla punktu przywracania,"+vbCrLf+vbCrLf+" np. Mój Punkt Przywracania na wszelki wypadek "+vbCrLf+vbCrLf+" lub u¿yj nazwy sugerowanej przez skrypt:",GetOS+" RemoveSpy_AIO - Przywracanie systemu","RemoveSpy_AIO_"+CurDate)
If InputMy = "" Then
LogDateTime
intTimeout = 2
intType = 48
strMessage = " Anulowano tworzenie punktu przywracania !"
strTitle = GetOS+" RemoveSpy_AIO - Przywracanie systemu"
Set WshShell = CreateObject("WScript.Shell")
intResult = WshShell.Popup(strMessage, intTimeout, strTitle, intType)
Set objFSO=CreateObject("Scripting.FileSystemObject")
outFile="C:\Windows\RemoveSpy_AIO.log"
Set objFile = objFSO.OpenTextFile(outFile, 8)
objFile.Write LogDateTime+" Przywracanie systemu - anulowano tworzenie punktu przywracania!" & vbCrLf
objFile.Close
Wscript.Quit
End If
LogDateTime
Set objFSO=CreateObject("Scripting.FileSystemObject")
outFile="C:\Windows\RemoveSpy_AIO.log"
Set objFile = objFSO.OpenTextFile(outFile, 8)
objFile.Write LogDateTime+" Przywracanie systemu - uruchomienie tworzenia punktu przywracania systemu" & vbCrLf
objFile.Close
swinmgmts = "winmgmts:\\.\root\default:Systemrestore"
GetObject(swinmgmts).CreateRestorePoint InputMy, 0, 100
LogDateTime
intTimeout = 3
intType = 64
strMessage = " Punkt przywracania"+vbCrLf+InputMy+vbCrLf+" zosta³ utworzony."
strTitle = GetOS+" RemoveSpy_AIO - Przywracanie systemu"
Set WshShell = CreateObject("WScript.Shell")
intResult = WshShell.Popup(strMessage, intTimeout, strTitle, intType)
Set objFSO=CreateObject("Scripting.FileSystemObject")
outFile="C:\Windows\RemoveSpy_AIO.log"
Set objFile = objFSO.OpenTextFile(outFile, 8)
objFile.Write LogDateTime+" Przywracanie systemu - punkt przywracania: """+InputMy+""" zosta³ utworzony" & vbCrLf
objFile.Close
End Sub
Function GetOS
Set objWMI = GetObject("winmgmts:{impersonationLevel=impersonate}\\" & _
".\root\cimv2")
Set colOS = objWMI.ExecQuery("Select * from Win32_OperatingSystem")
For Each objOS in colOS
strOSName = objOS.Caption
If instr(strOSName, "Windows 7") Then
GetOS = "Win7"
ElseIf instr(strOSName, "Vista") Then
GetOS = "Vista"
ElseIf instr(strOSName, "Windows XP") Then
GetOS = "Windows XP"
ElseIf instr(strOSName, "Windows 8.1") Then
GetOS = "Win81"
ElseIf instr(strOSName, "Windows 10") Then
GetOS = "Win10"
End If
Next
End Function
Function LogDateTime
LogDateTime = Year(Date) & "-" & Right(String(2, "0") & Month(Date),2) & "-" & Day(Date) & "_" & Right(String(2, "0") & Hour(Time),2) & "-" & Right(String(2, "0") & Minute(Time),2) & "-" & Right(String(2, "0") & Second(Time),2)
End Function
Skrypt tworzy punkt przywracania systemu z domyślna nazwa, fajnie by było gdyby po np. 10 sekundach bez interakcji użytkownika wykonał go
Czy używając funkcji InputMy = InputBox ()
da radę osiągnąć auto-odliczanie w dół np od 10 co 1 i czy będzie to widoczne na wywołanym oknie czy też nie?
Wiem że tutaj da radę: intResult = WshShell.Popup(strMessage, intTimeout, strTitle, intType)