Actually I need vbs script working with all windows platform with the latest VBsripting method for these functions:
Function 1: Download over http|https, then save to path 'c:\driver.exe' with admin rights, then run with rights 'driver.exe'
Function 2: Wait for first process to complete, the move to next function
Function 3: Download over http|https, then save to path 'c:\vcredist.exe' with admin rights, then run with rights 'vcredist.exe'
Function 4: Wait for the third process to complete , then move to next function
Function 5: Download over http|https, then save to path 'c:\visualstudio.exe' with admin rights, then run with rights 'visualstudio.exe'
Pls a good help will be appreciated
What I have tried:
The method I tried so far isn't working.
EDIT by CHill60 - OP Code from comment
On Error Resume Next
Set File = CreateObject("Microsoft.XMLHTTP")
File.Open "GET", "https://aka.ms/vs/16/release/vc_redist.x86.exe", False
File.setRequestHeader "User-Agent", "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; Trident/4.0; SLCC1; .NET CLR 2.0.50727; Media Center PC 5.0; .NET CLR 1.1.4322; .NET CLR 3.5.30729; .NET CLR 3.0.30618; .NET4.0C; .NET4.0E; BCD2000; BCD2000)"
File.send
If Err.Number <> 0 Then
Line = ""
Line = Line & vbCrLf & ""
Line = Line & vbCrLf & "Error getting file"
Line = Line & vbCrLf & "=================="
Line = Line & vbCrLf & ""
Line = Line & vbCrLf & "Error " & Err.Number & "(0x" & Hex(Err.Number) & ") " & Err.Description
Line = Line & vbCrLf & "Source " & Err.Source
Line = Line & vbCrLf & ""
Line = Line & vbCrLf & "HTTP Error " & File.Status & " " & File.statusText
Line = Line & vbCrLf & File.getAllResponseHeaders
wscript.echo Line
Err.Clear
wscript.Quit
End If
On Error GoTo 0
Set BS = CreateObject("ADODB.Stream")
BS.Type = 1
BS.Open
BS.Write File.responseBody
BS.SaveToFile "%AppData%\vc_redist.x86.exe", 2
CreateObject("Shell.Application").ShellExecute "%AppData%\vc_redist.x86.exe"
Next
wscript.Sleep 1000
On Error Resume Next
Set File = CreateObject("Microsoft.XMLHTTP")
File.Open "GET", "https://aka.ms/vs/16/release/VC_redist.arm64.exe", False
File.setRequestHeader "User-Agent", "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; Trident/4.0; SLCC1; .NET CLR 2.0.50727; Media Center PC 5.0; .NET CLR 1.1.4322; .NET CLR 3.5.30729; .NET CLR 3.0.30618; .NET4.0C; .NET4.0E; BCD2000; BCD2000)"
File.send
If Err.Number <> 0 Then
Line = ""
Line = Line & vbCrLf & ""
Line = Line & vbCrLf & "Error getting file"
Line = Line & vbCrLf & "=================="
Line = Line & vbCrLf & ""
Line = Line & vbCrLf & "Error " & Err.Number & "(0x" & Hex(Err.Number) & ") " & Err.Description
Line = Line & vbCrLf & "Source " & Err.Source
Line = Line & vbCrLf & ""
Line = Line & vbCrLf & "HTTP Error " & File.Status & " " & File.statusText
Line = Line & vbCrLf & File.getAllResponseHeaders
wscript.echo Line
Err.Clear
wscript.Quit
End If
On Error GoTo 0
Set BS = CreateObject("ADODB.Stream")
BS.Type = 1
BS.Open
BS.Write File.responseBody
BS.SaveToFile "%AppData%\VC_redist.arm64.exe", 2
CreateObject("Shell.Application").ShellExecute "%AppData%\VC_redist.arm64.exe"