vm-guest-tools.bat 2.65 KB
Newer Older
Stefan Scherer's avatar
Stefan Scherer committed
1
2
if not exist "C:\Windows\Temp\7z1900-x64.msi" (
    powershell -Command "(New-Object System.Net.WebClient).DownloadFile('https://www.7-zip.org/a/7z1900-x64.msi', 'C:\Windows\Temp\7z1900-x64.msi')" <NUL
3
)
Stefan Scherer's avatar
Stefan Scherer committed
4
5
if not exist "C:\Windows\Temp\7z1900-x64.msi" (
    powershell -Command "Start-Sleep 5 ; (New-Object System.Net.WebClient).DownloadFile('https://www.7-zip.org/a/7z1900-x64.msi', 'C:\Windows\Temp\7z1900-x64.msi')" <NUL
Stefan Scherer's avatar
Stefan Scherer committed
6
)
Stefan Scherer's avatar
Stefan Scherer committed
7
msiexec /qb /i C:\Windows\Temp\7z1900-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" (
Stefan Scherer's avatar
Stefan Scherer committed
21
    powershell -Command "(New-Object System.Net.WebClient).DownloadFile('https://softwareupdate.vmware.com/cds/vmw-desktop/ws/15.0.4/12990004/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
Sync    
Stefan Scherer committed
46
cmd /c for %%i in (C:\Windows\Temp\virtualbox\cert\vbox*.cer) do C:\Windows\Temp\virtualbox\cert\VBoxCertUtil add-trusted-publisher %%i --root %%i
47
cmd /c C:\Windows\Temp\virtualbox\VBoxWindowsAdditions.exe /S
Stefan Scherer's avatar
Stefan Scherer committed
48
rd /S /Q "C:\Windows\Temp\virtualbox"
49
50
goto :done

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

59
:done
Stefan Scherer's avatar
Stefan Scherer committed
60
msiexec /qb /x C:\Windows\Temp\7z1900-x64.msi