Download IE8 using Batch or Script

Status
Not open for further replies.

Osiris

Golden Master
Messages
36,817
Location
Kentucky
I'm trying to figure out how to download IE8 using a batch file. The one below downloads IE8 in European. I renamed parts of the code to what I thought they should be, maybe I did that part right but other parts needed to be changed as well, or maybe I did it wrong all together.

This is the correct IE8 ENU download URL

http://download.microsoft.com/downl...E-936B-73AC6F95AE11/IE8-WindowsXP-x86-ENU.exe

I renamed IE8-WindowsVista-x86-DEU.exe to IE8-WindowsXP-x86-ENU.exe, still didnt work

It downloads a file but its corrupt. I want to have this, if possible for people with spyware issues that cant download programs from the net because of site redirections, etc.

Thoughts?

Code:
@echo off 
if exist download-IE8.cs del download-IE8.cs 
echo using System; > download-IE8.cs 
echo using System.Net; >> download-IE8.cs 
echo using System.IO; >> download-IE8.cs 
echo. >> download-IE8.cs 
echo namespace Download_IE8 >> download-IE8.cs 
echo { >> download-IE8.cs 
echo     class Program >> download-IE8.cs 
echo     { >> download-IE8.cs 
echo         static void Main(string[] args) >> download-IE8.cs 
echo         { >> download-IE8.cs 
echo             if (File.Exists("IE8-WindowsVista-x86-DEU.exe")) >> download-IE8.cs 
echo                 File.Delete("IE8-WindowsVista-x86-DEU.exe"); >> download-IE8.cs 
echo. >> download-IE8.cs 
echo             try >> download-IE8.cs 
echo             { >> download-IE8.cs 
echo                 HttpWebRequest request = (HttpWebRequest)WebRequest.Create("[URL="http://download.microsoft.com/download/3/D/C/3DC5DC1B-2B60-487A-BAE2-732662BC0886/IE8-WindowsVista-x86-DEU.exe%22);"]http://download.microsoft.com/download/3/D/C/3DC5DC1B-2B60-487A-BAE2-732662BC0886/IE8-WindowsVista-x86-DEU.exe");[/URL] >> download-IE8.cs 
echo                 request.UserAgent = "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1;)"; >> download-IE8.cs 
echo                 request.AllowWriteStreamBuffering = false; >> download-IE8.cs 
echo                 request.Timeout = 10000; >> download-IE8.cs 
echo. >> download-IE8.cs 
echo                 using (Stream s = request.GetResponse().GetResponseStream()) >> download-IE8.cs 
echo                 { >> download-IE8.cs 
echo                     FileStream fs = new FileStream("IE8-WindowsVista-x86-DEU.exe", FileMode.Create); >> download-IE8.cs 
echo. >> download-IE8.cs 
echo                     byte[] read = new byte[1024]; >> download-IE8.cs 
echo                     int count = s.Read(read, 0, read.Length); >> download-IE8.cs 
echo. >> download-IE8.cs 
echo                     while (count != 0) >> download-IE8.cs 
echo                     { >> download-IE8.cs 
echo                         fs.Write(read, 0, count); >> download-IE8.cs 
echo                         count = s.Read(read, 0, read.Length); >> download-IE8.cs 
echo. >> download-IE8.cs 
echo                         Console.Write("."); >> download-IE8.cs 
echo                     } >> download-IE8.cs 
echo                 } >> download-IE8.cs 
echo. >> download-IE8.cs 
echo                 Console.WriteLine(); >> download-IE8.cs 
echo                 Console.WriteLine("Done."); >> download-IE8.cs 
echo. >> download-IE8.cs 
echo                 System.Threading.Thread.Sleep(5000); >> download-IE8.cs 
echo                 System.Diagnostics.Process.Start("IE8-WindowsVista-x86-DEU.exe"); >> download-IE8.cs 
echo             } >> download-IE8.cs 
echo             catch (Exception ex) >> download-IE8.cs 
echo             { >> download-IE8.cs 
echo                 Console.WriteLine("Error: " + ex.Message); >> download-IE8.cs 
echo             } >> download-IE8.cs 
echo         } >> download-IE8.cs 
echo     } >> download-IE8.cs 
echo } >> download-IE8.cs 
echo. >> download-IE8.cs 
if not exist download-IE8.cs goto ERROR1 
"%WINDIR%\Microsoft.NET\Framework\v3.5\csc.exe" download-IE8.cs 
download-IE8.exe 
if not exists download-IE8.exe goto ERROR2 
:ERROR1 
echo Could not create C# source file. 
goto END 
:ERROR2 
echo Could not create executable to download IE8. 
goto END 
:END
 
I guess I looked into to much, this time all I did was replaced the DEU link with the ENU link and it worked. :thumbsup:
 
i didn't create a script to download ie8. instead i had to create a script to download company application installers then copy updated files.

Code:
; Advanced example - downloading in the background
Local $hDownload = InetGet("http://www.autoitscript.com/autoit3/files/beta/update.dat", @TempDir & "\update.dat", 1, 1)
Do
    Sleep(250)
Until InetGetInfo($hDownload, 2)    ; Check if the download is complete.
Local $nBytes = InetGetInfo($hDownload, 0)
InetClose($hDownload)   ; Close the handle to release resourcs.
MsgBox(0, "", "Bytes read: " & $nBytes)

;execute file
Local $val = RunWait(@WindowsDir & "\Notepad.exe", @WindowsDir, @SW_MAXIMIZE)
; script waits until Notepad closes
MsgBox(0, "Program returned with exit code:", $val)

this script will download a file and execute the command. you'll need to change the url, the download file name (update.dat), and the execute command (windir notepad.exe)

install autoit, copy & paste, compile, execute

edit - i ran onto problems with av's...you could imagine as the exe is downloading and executing files. To get around this, I compiled a blank file in autoit and replaced upx.exe with the 0 byte exe in Autoit's program files folder
 
Status
Not open for further replies.
Back
Top Bottom