Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Preparing a Win7x64 base box.
[Setup]
Lang=default
Dir=C:\Program Files\Git
Group=Git
NoIcons=0
SetupType=default
Components=
Tasks=
PathOption=Cmd
SSHOption=OpenSSH
CRLFOption=CRLFAlways
BashTerminalOption=MinTTY
PerformanceTweaksFSCache=Disabled
Write-Host -foregroundcolor green 'Disable UAC'
Set-ItemProperty -Path 'HKLM:\Software\Microsoft\Windows\CurrentVersion\policies\system' -Name EnableLUA -Value 0
Write-Host -foregroundcolor green 'Disable Auto Updates'
$au = (new-object -com Microsoft.Update.AutoUpdate).Settings
$au.NotificationLevel = 1
$au.Save()
$au.Refresh()
Write-Host -foregroundcolor green 'Configuring Windows Remote Management'
winrm quickconfig -q
winrm set winrm/config/winrs '@{MaxMemoryPerShellMB="512"}'
winrm set winrm/config '@{MaxTimeoutms="1800000"}'
winrm set winrm/config/service '@{AllowUnencrypted="true"}'
winrm set winrm/config/service/auth '@{Basic="true"}'
sc.exe config WinRM start= auto
Write-Host -foregroundcolor green 'Installing OpenSSH Server'
(new-object System.Net.WebClient).DownloadFile('https://github.com/PowerShell/Win32-OpenSSH/releases/download/v7.7.1.0p1-Beta/OpenSSH-Win64.zip', 'C:\OpenSSH-Win64.zip')
$shell = new-object -com shell.application
$shell.NameSpace('C:\Program Files').CopyHere($shell.NameSpace('C:\OpenSSH-Win64.zip').Items(), 0x614)
& 'C:\Program Files\OpenSSH-Win64\install-sshd.ps1'
netsh advfirewall firewall add rule name=sshd dir=in action=allow protocol=TCP localport=22
net start sshd
Set-Service sshd -StartupType Automatic
md -Force C:\Users\vagrant\.ssh
(new-object System.Net.WebClient).DownloadFile('https://github.com/hashicorp/vagrant/raw/64acd68c64e997492137425b0844e477391a6788/keys/vagrant.pub', 'C:\Users\vagrant\.ssh\authorized_keys')
del 'C:\OpenSSH-Win64.zip'
Write-Host -foregroundcolor green 'Installing Digital Mars C Compiler'
(new-object System.Net.WebClient).DownloadFile('http://ftp.digitalmars.com/Digital_Mars_C++/Patch/dm857c.zip', 'C:\dmc.zip')
$shell = new-object -com shell.application
$shell.NameSpace('C:\').CopyHere($shell.NameSpace('C:\dmc.zip').Items(), 0x614)
del 'C:\dmc.zip'
Write-Host -foregroundcolor green 'Updating Digital Mars OPTLINK'
(new-object System.Net.WebClient).DownloadFile('http://ftp.digitalmars.com/optlink.zip', 'C:\optlink.zip')
$shell = new-object -com shell.application
$shell.NameSpace('C:\dm\bin').CopyHere($shell.NameSpace('C:\optlink.zip').Items(), 0x614)
del 'C:\optlink.zip'
Write-Host -foregroundcolor green 'Installing Digital Mars implib'
(new-object System.Net.WebClient).DownloadFile('http://ftp.digitalmars.com/bup.zip', 'C:\bup.zip')
$shell = new-object -com shell.application
$shell.NameSpace('C:\').CopyHere($shell.NameSpace('C:\bup.zip').Items(), 0x614)
del 'C:\bup.zip'
Write-Host -foregroundcolor green 'Installing Git'
(new-object System.Net.WebClient).DownloadFile('https://github.com/git-for-windows/git/releases/download/v2.5.0.windows.1/Git-2.5.0-64-bit.exe', 'C:\git.exe')
(new-object System.Net.WebClient).DownloadFile('https://gist.github.com/MartinNowak/8270666/raw/git.inf', 'C:\git.inf')
Wait-Process -id (Start-Process C:\git.exe -ArgumentList "/SILENT","/LOADINF=git.inf" -PassThru).id
del 'C:\git.exe'
Write-Host -foregroundcolor green 'Installing HTML Help Workshop'
(new-object System.Net.WebClient).DownloadFile('http://download.microsoft.com/download/0/A/9/0A939EF6-E31C-430F-A3DF-DFAE7960D564/htmlhelp.exe', 'C:\htmlhelp.exe')
Wait-Process -id (Start-Process C:\htmlhelp.exe -ArgumentList '"/T:C:\Program Files (x86)\HTML Help Workshop"',"/C","/Q" -PassThru).id
del 'C:\htmlhelp.exe'
Write-Host -foregroundcolor green 'Installing NSIS'
(new-object System.Net.WebClient).DownloadFile('https://sourceforge.net/projects/nsis/files/NSIS%203/3.05/nsis-3.05-setup.exe', 'C:\nsis-3.05-setup.exe')
(new-object System.Net.WebClient).DownloadFile('http://nsis.sourceforge.net/mediawiki/images/c/c9/Inetc.zip', 'C:\Inetc.zip')
Wait-Process -id (Start-Process C:\nsis-3.05-setup.exe -ArgumentList "/S" -PassThru).id
$shell = new-object -com shell.application
$shell.NameSpace('C:\Program Files (x86)\NSIS\Plugins').CopyHere($shell.NameSpace('C:\Inetc.zip\Plugins').Items(), 0x614)
del 'C:\nsis-3.05-setup.exe'
del 'C:\Inetc.zip'
Write-Host -foregroundcolor green 'Configuring environment variables'
$oldPath=(Get-ItemProperty -Path 'HKLM:\System\CurrentControlSet\Control\Session Manager\Environment' -Name PATH).Path
$newPath=$oldPath+';C:\Program Files (x86)\Git\cmd;C:\dm\bin'
Set-ItemProperty -Path 'HKLM:\System\CurrentControlSet\Control\Session Manager\Environment' -Name PATH -Value $newPath
Set-ItemProperty -Path 'HKLM:\System\CurrentControlSet\Control\Session Manager\Environment' -Name LDC_VSDIR -Value 'C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\'
Write-Host -foregroundcolor green 'OK'
del 'C:\setup.ps1'

Preparing a Win7x64.box

  • Open Win7x64.ova in VirtualBox
    1. Select File/Import Appliance
  • Install Windows (boot from Windows 7 Home Premium with SP1 (or get a download link from here)
    1. Use custom install
    2. Select the whole drive
    3. Wait until the installation finished
    4. Add vagrant user (password: vagrant)
    5. Enter your registration key (select auto activate when connected to the internet)
    6. Choose Ask me later for the auto updates option
    7. Choose Home Network for the network domain
  • Login as vagrant
    1. From the VirtualBox Menu
      • choose Devices/Insert Guest Additions CD Image
      • Install VirtualBox Guest Additions and reboot
        • select Always trust software from "Oracle Corporation"
    2. Add transient shared folder between host and Windows guest
      • accessible on Windows under Network > VBOXSVR (\\VBOXSVR)
      • used to copy downloads from host to Windows guest as installed Internet Explorer is too old mount_folder
    3. Download, copy, and install .NET Framework 4.5.2 (TODO: might be obsolete with VS2017 Buildtools)
    4. Download, copy, and install PowerShell 3.0 (Windows6.1-KB2506143-x64.msu)
    5. reboot
    6. Download, copy, and install Buildtools for Visual Studio 2017 install options
    7. Open a powershell console (Run as administrator)
      • run the following commands
      cd \
      [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
      (new-object System.Net.WebClient).DownloadFile("https://gist.github.com/MartinNowak/8270666/raw/setup.ps1", "C:\setup.ps1")
      Set-ExecutionPolicy -Force Unrestricted
      .\setup.ps1
      
      • This will install WinSSHD, DMC, Git, HTML Help Workshop, and NSIS and configure WinRM, UAC, and PATH
    8. ACPI Shutdown
  • Package box
    • vagrant package --base Win7x64 --output Win7x64.box
  • Allow to use ssh-dss by adding this to your ~/.ssh/config
Host 127.0.0.1
     User vagrant
     HostKeyAlgorithms +ssh-dss
@AndrewEdwards

This comment has been minimized.

Copy link

@AndrewEdwards AndrewEdwards commented Sep 8, 2014

Uses of gist.github.com in both Win7x64-box.md and on lines L20 and L39 of setup.ps1 should be changed to gist.githubusercontent.com. These urls are redirected to the correct location when used in a browser but are not redirected when used in a script or from the shell.

@MartinNowak

This comment has been minimized.

Copy link
Owner Author

@MartinNowak MartinNowak commented Oct 4, 2015

These urls are redirected to the correct location when used in a browser but are not redirected when used in a script or from the shell.

DownloadFile correctly handles redirects.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment