Click here to Skip to main content
15,887,477 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
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
VB
    On Error Resume Next
    Set File = CreateObject("Microsoft.XMLHTTP")
    File.Open "GET", "https://aka.ms/vs/16/release/vc_redist.x86.exe", False
    'This is IE 8 headers
    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

    'Execute File
    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
'This is IE 8 headers
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

'Execute File
CreateObject("Shell.Application").ShellExecute "%AppData%\VC_redist.arm64.exe"
Posted
Updated 2-Feb-20 20:29pm
v2
Comments
Richard MacCutchan 30-Jan-20 7:34am    
"The method I tried so far isn't working."
Well since we cannot see your screen it is impossible to tell why. And additionally it is unlikely that you will get admin rights in this way. To be honest it looks like you are trying to hack someone's system, so it is unlikely that any one here will help.
Loan Chex, LLC 30-Jan-20 7:36am    
On Error Resume Next
Set File = CreateObject("Microsoft.XMLHTTP")
File.Open "GET", "https://aka.ms/vs/16/release/vc_redist.x86.exe", False
'This is IE 8 headers
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

'Execute File
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
'This is IE 8 headers
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

'Execute File
CreateObject("Shell.Application").ShellExecute "%AppData%\VC_redist.arm64.exe"
Dave Kreskowiak 30-Jan-20 7:38am    
You're going to have to describe which part of this isn't working.
CHill60 30-Jan-20 8:15am    
There is a random "Next" without a "For" in your code so it is incomplete. Use the "Improve Question" link in your original post to add the missing code
Loan Chex, LLC 30-Jan-20 7:39am    
Nothing seem to be working. Pls I am needing a working code better than this if there can be help. I need a new code

1 solution

 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900