vm-guest-tools.bat 2.67 KB
Newer Older
1
if not exist "C:\Windows\Temp\7z920-x64.msi" (
2
    powershell -Command "(New-Object System.Net.WebClient).DownloadFile('https://www.7-zip.org/a/7z920-x64.msi', 'C:\Windows\Temp\7z920-x64.msi')" <NUL
3
)
Stefan Scherer's avatar
Stefan Scherer committed
4
if not exist "C:\Windows\Temp\7z920-x64.msi" (
5
    powershell -Command "Start-Sleep 5 ; (New-Object System.Net.WebClient).DownloadFile('https://www.7-zip.org/a/7z920-x64.msi', 'C:\Windows\Temp\7z920-x64.msi')" <NUL
Stefan Scherer's avatar
Stefan Scherer committed
6
)
7
msiexec /qb /i C:\Windows\Temp\7z920-x64.msi
8

9 10
if "%PACKER_BUILDER_TYPE%" equ "vmware-iso" goto :vmware
if "%PACKER_BUILDER_TYPE%" equ "virtualbox-iso" goto :virtualbox
11
if "%PACKER_BUILDER_TYPE%" equ "parallels-iso" goto :parallels
12
goto :done
13 14 15

:vmware

16
if exist "C:\Users\vagrant\windows.iso" (
17
    move /Y C:\Users\vagrant\windows.iso C:\Windows\Temp
18 19
)

20
if not exist "C:\Windows\Temp\windows.iso" (
21
    powershell -Command "(New-Object System.Net.WebClient).DownloadFile('https://softwareupdate.vmware.com/cds/vmw-desktop/ws/15.0.2/10952284/windows/packages/tools-windows.tar', 'C:\Windows\Temp\vmware-tools.tar')" <NUL
Stefan Scherer's avatar
Stefan Scherer committed
22 23
    cmd /c ""C:\Program Files\7-Zip\7z.exe" x C:\Windows\Temp\vmware-tools.tar -oC:\Windows\Temp"
    FOR /r "C:\Windows\Temp" %%a in (VMware-tools-windows-*.iso) DO REN "%%~a" "windows.iso"
24
    rd /S /Q "C:\Program Files (x86)\VMWare"
25 26
)

27
cmd /c ""C:\Program Files\7-Zip\7z.exe" x "C:\Windows\Temp\windows.iso" -oC:\Windows\Temp\VMWare"
28
cmd /c C:\Windows\Temp\VMWare\setup.exe /S /v"/qn REBOOT=R\"
29

30 31
del /Q "C:\Windows\Temp\vmware-tools.tar"
del /Q "C:\Windows\Temp\windows.iso"
32
rd /S /Q "C:\Windows\Temp\VMware"
33
goto :done
34 35

:virtualbox
36

Stefan Scherer's avatar
Stefan Scherer committed
37 38 39 40 41
if exist "C:\Users\vagrant\VBoxGuestAdditions.iso" (
    move /Y C:\Users\vagrant\VBoxGuestAdditions.iso C:\Windows\Temp
)

if not exist "C:\Windows\Temp\VBoxGuestAdditions.iso" (
Stefan Scherer's avatar
Stefan Scherer committed
42
    powershell -Command "(New-Object System.Net.WebClient).DownloadFile('https://download.virtualbox.org/virtualbox/5.2.26/VBoxGuestAdditions_5.2.26.iso', 'C:\Windows\Temp\VBoxGuestAdditions.iso')" <NUL
Stefan Scherer's avatar
Stefan Scherer committed
43 44
)

dylanmei's avatar
dylanmei committed
45
cmd /c ""C:\Program Files\7-Zip\7z.exe" x C:\Windows\Temp\VBoxGuestAdditions.iso -oC:\Windows\Temp\virtualbox"
Stefan Scherer's avatar
Stefan Scherer committed
46 47
certutil -addstore -f "TrustedPublisher" C:\Windows\Temp\virtualbox\cert\vbox-sha256.cer
certutil -addstore -f "TrustedPublisher" C:\Windows\Temp\virtualbox\cert\vbox-sha1.cer
48
cmd /c C:\Windows\Temp\virtualbox\VBoxWindowsAdditions.exe /S
Stefan Scherer's avatar
Stefan Scherer committed
49
rd /S /Q "C:\Windows\Temp\virtualbox"
50 51
goto :done

52 53
:parallels
if exist "C:\Users\vagrant\prl-tools-win.iso" (
jcoutch's avatar
jcoutch committed
54
	move /Y C:\Users\vagrant\prl-tools-win.iso C:\Windows\Temp
jcoutch's avatar
jcoutch committed
55
	cmd /C "C:\Program Files\7-Zip\7z.exe" x C:\Windows\Temp\prl-tools-win.iso -oC:\Windows\Temp\parallels
56
	cmd /C C:\Windows\Temp\parallels\PTAgent.exe /install_silent
Stefan Scherer's avatar
Stefan Scherer committed
57
	rd /S /Q "C:\Windows\Temp\parallels"
58 59
)

60
:done
61
msiexec /qb /x C:\Windows\Temp\7z920-x64.msi