-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathwin-guest-tools.nsis
More file actions
765 lines (654 loc) · 19.9 KB
/
Copy pathwin-guest-tools.nsis
File metadata and controls
765 lines (654 loc) · 19.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
#!Nsis Installer Command Script
# @configure_input@
# To build an installer from the script you would normally do:
#
# makensis -D{SPICE,OVIRT} win-guest-tools.nsis
#
# which will generate the output file 'spice-guest-tools-$VERSION.exe' or
# 'ovirt-guest-tools-setup.exe' which are Windows
# installers containing your program.
#
#
#
# Copyright (c) 2012-2017 Red Hat, Inc
# Copyright (c) 2017 Lev Veyde <lveyde@redhat.com>
# Copyright (c) 2012 Grant Williamson <grant.williamson@gmail.com>
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"),
# to deal in the Software without restriction, including without limitation
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
# and/or sell copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# DEALINGS IN THE SOFTWARE.
#
SetCompressor /SOLID lzma
!include "driver.nsh"
!include "FileFunc.nsh"
!include "WinVer.nsh"
!include "x64.nsh"
!ifdef SPICE
!define FILENAME "utm-guest-tools"
!define NAME "UTM Guest Tools"
!define PUBLISHER "Turing Software, LLC"
!define REGKEYNAME "SpiceGuestTools"
!define URL "https://getutm.app"
!else ifdef OVIRT
!define FILENAME "ovirt-guest-tools-setup"
!define NAME "oVirt Guest Tools"
!define PUBLISHER "The oVirt Project"
!define REGKEYNAME "oVirtGuestTools"
!define URL "http://www.ovirt.org/Home"
!else
!error "OVIRT or SPICE symbol should passed to makensis with the -D flag"
!endif
!ifndef VERSION
!error "-DVERSION=<version> should be passed to makensis, see Makefile"
!endif
!ifndef DISPLAYED_VERSION
!define DISPLAYED_VERSION "${VERSION}"
!endif
Name "${NAME}"
Caption "${NAME} Installer"
OutFile "${FILENAME}-${VERSION}.exe"
InstallDir "$PROGRAMFILES\${NAME}"
BrandingText " "
# SilentInstall silent
ShowInstDetails nevershow
# ShowUninstDetails hide
# Hardware ID shared by both the display-only (viogpudo) and the
# experimental 3D accelerated (viogpu3d) virtio GPU drivers
!define GPU_HWID "PCI\VEN_1AF4&DEV_1050&SUBSYS_11001AF4&REV_01"
Var GraphicsDialog
Var Enable3DCheckbox
Var Enable3D
!include "MUI2.nsh"
!include "nsDialogs.nsh"
!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_LICENSE virtio-win_license.txt
Page custom GraphicsPageCreate GraphicsPageLeave
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_PAGE_FINISH
!insertmacro MUI_UNPAGE_WELCOME
!insertmacro MUI_UNPAGE_INSTFILES
!insertmacro MUI_UNPAGE_FINISH
!insertmacro MUI_LANGUAGE "English"
!include "DumpLog.nsh"
XPStyle on
RequestExecutionLevel admin
ComponentText "Select which optional components you want to install."
DirText "Please select the installation folder."
Section "install"
SectionIn RO
Call StopServices
SetOutPath "$INSTDIR"
File "version.txt"
!ifdef OVIRT
File "bin\vc_redist.arm64.exe"
File "bin\vcredist_x86.exe"
File "bin\OVirtGuestService.exe"
File "bin\ovirt-guest-agent.ini"
File "bin\default.ini"
File "bin\default-logger.ini"
CreateDirectory "$INSTDIR\hooks\after_hibernation"
CreateDirectory "$INSTDIR\hooks\before_hibernation"
CreateDirectory "$INSTDIR\hooks\after_migration"
CreateDirectory "$INSTDIR\hooks\before_migration"
${If} ${IsNativeARM64}
ExecWait '"$INSTDIR\vc_redist.arm64.exe" /q'
${Else}
ExecWait '"$INSTDIR\vcredist_x86.exe" /q'
${EndIf}
!endif
!ifdef SPICE
File "bin\vc_redist.arm64.exe"
File "bin\spice-webdavd-x86-2.2.msi"
File "bin\spice-webdavd-x86-latest.msi"
File "bin\spice-webdavd-x64-2.2.msi"
File "bin\spice-webdavd-x64-latest.msi"
File "bin\spice-webdavd-arm64-latest.msi"
File "bin\qemu-ga-i386.msi"
File "bin\qemu-ga-x86_64.msi"
${If} ${IsNativeARM64}
ExecWait '"$INSTDIR\vc_redist.arm64.exe" /q'
${EndIf}
!endif
SetOutPath "$INSTDIR\32"
File "bin\vdagent_x86\vdagent.exe"
File "bin\vdagent_x86\vdservice.exe"
SetOutPath "$INSTDIR\64"
File "bin\vdagent_x64\vdagent.exe"
File "bin\vdagent_x64\vdservice.exe"
SetOutPath "$INSTDIR\ARM64"
File "bin\vdagent_arm64\vdagent.exe"
File "bin\vdagent_arm64\vdservice.exe"
SetOutPath "$INSTDIR\drivers"
File /r /x *.pdb drivers\virtio\*.*
Push "vioserial"
Push "vioser"
Push "PCI\VEN_1AF4&DEV_1003&SUBSYS_00031AF4"
Call InstallDriver
Call InstallQemuGuestAgent
${IfNot} ${IsNativeARM64}
${AndIfNot} ${AtLeastWin11}
${if} ${AtLeastWin8}
Push "qxldod"
Push "qxldod"
${else}
Push "qxl"
Push "qxl"
${endif}
Push "PCI\VEN_1b36&DEV_0100&SUBSYS_11001af4"
Call InstallDriver
${EndIf}
Push "Balloon"
Push "balloon"
Push "PCI\VEN_1AF4&DEV_1002&SUBSYS_00051AF4&REV_00"
Call InstallBalloonDriver
Push "viostor"
Push "viostor"
Push "PCI\VEN_1AF4&DEV_1001&SUBSYS_00021AF4&REV_00"
Call InstallDriver
${If} ${AtLeastWinVista}
Push "vioscsi"
Push "vioscsi"
Push "PCI\VEN_1AF4&DEV_1004&SUBSYS_00081AF4&REV_00"
Call InstallDriver
${EndIf}
${IfNot} ${IsNativeARM64}
Push "."
Push "qemupciserial"
Push "PCI\VEN_1B36&DEV_0002"
Call InstallDriver
Push "."
Push "qemupciserial"
Push "PCI\VEN_1B36&DEV_0003"
Call InstallDriver
Push "."
Push "qemupciserial"
Push "PCI\VEN_1B36&DEV_0004"
Call InstallDriver
${EndIf}
Push "NetKVM"
Push "netkvm"
Push "PCI\VEN_1AF4&DEV_1000&SUBSYS_00011AF4&REV_00"
Call InstallDriver
${IfNot} ${IsNativeARM64}
# Install sriov driver
${If} ${AtLeastWin8}
${OrIf} ${AtLeastWin2012}
Push "sriov"
Push "sriov"
Push "VIOPROT"
Call InstallDriver
${EndIf}
# Install Q35 smbus driver
${If} ${IsWin2008}
${OrIf} ${AtLeastWin11}
Push "smbus"
Push "smbus"
Push "PCI\VEN_8086&DEV_2930&SUBSYS_11001AF4"
Call InstallDriver
${EndIf}
# Install Q35 qemufwcfg driver
${If} ${AtLeastWin10}
${OrIf} ${AtLeastWin2016}
Push "qemufwcfg"
Push "qemufwcfg"
Push "ACPI\QEMU0002"
Call InstallDriver
${EndIf}
${If} ${AtLeastWin8}
${OrIf} ${AtLeastWin2012}
Push "viofs"
Push "viofs"
Push "PCI\VEN_1AF4&DEV_105A&SUBSYS_11001AF4&REV_01"
Call InstallDriver
${EndIf}
${EndIf}
# Install rng driver
${If} ${AtLeastWinVista}
Push "viorng"
Push "viorng"
Push "PCI\VEN_1AF4&DEV_1005"
Call InstallDriver
${EndIf}
${If} ${AtLeastWin7}
${OrIf} ${AtLeastWin2008}
Push "pvpanic"
Push "pvpanic"
Push "ACPI\QEMU0001"
Call InstallDriver
Push "vioinput"
Push "vioinput"
Push "PCI\VEN_1AF4&DEV_1052&SUBSYS_11001AF4&REV_01"
Call InstallDriver
${EndIf}
${If} ${AtLeastWin10}
${OrIf} ${AtLeastWin2016}
${If} $Enable3D == ${BST_CHECKED}
Push "viogpu3d"
Push "viogpu3d"
${Else}
Push "viogpudo"
Push "viogpudo"
${EndIf}
Push "${GPU_HWID}"
Call InstallDriver
${EndIf}
${If} ${AtLeastWin10}
${OrIf} ${AtLeastWin2016}
Push "viomem"
Push "viomem"
Push "PCI\VEN_1AF4&DEV_1058&SUBSYS_11001AF4&REV_01"
Call InstallDriver
${EndIf}
!ifdef OVIRT
Call InstallOVirtAgentService
!endif
!ifdef SPICE
Call InstallSpiceWebdavd
Call InstallGuestAgent
!endif
Call InstallVdAgentService
# No longer needed
#${If} ${IsNativeARM64}
# Call DisableFallbackDisplay
#${EndIf}
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${REGKEYNAME}" \
"DisplayName" "${NAME} ${DISPLAYED_VERSION}"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${REGKEYNAME}" \
"DisplayVersion" "${DISPLAYED_VERSION}"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${REGKEYNAME}" \
"Publisher" "${PUBLISHER}"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${REGKEYNAME}" \
"URLInfoAbout" "${URL}"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${REGKEYNAME}" \
"UninstallString" "$\"$INSTDIR\Uninstall ${FILENAME}$\""
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${REGKEYNAME}" \
"QuietUninstallString" "$\"$INSTDIR\Uninstall ${FILENAME}$\" /S"
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${REGKEYNAME}" \
"NoModify" "1"
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${REGKEYNAME}" \
"NoRepair" "1"
${GetSize} "$INSTDIR" "/S=0K" $0 $1 $2
IntFmt $0 "0x%08X" $0
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${REGKEYNAME}" \
"EstimatedSize" "$0"
SectionEnd
Section "Uninstall"
Call un.StopServices
Call un.UninstallServices
Call un.UninstallQemuGuestAgent
!ifdef SPICE
Call un.UninstallSpiceWebdavd
Call un.UninstallGuestAgent
!endif
${If} ${IsNativeARM64}
Call un.EnableFallbackDisplay
${EndIf}
SetOutPath "$TEMP"
Delete /rebootok "$INSTDIR\version.txt"
Delete /rebootok "$INSTDIR\Uninstall ${FILENAME}.exe"
Delete /rebootok "$INSTDIR\32\vdagent.exe"
Delete /rebootok "$INSTDIR\32\vdservice.exe"
RMDir /rebootok "$INSTDIR\32"
Delete /rebootok "$INSTDIR\64\vdagent.exe"
Delete /rebootok "$INSTDIR\64\vdservice.exe"
RMDir /rebootok "$INSTDIR\64"
Delete /rebootok "$INSTDIR\ARM64\vdagent.exe"
Delete /rebootok "$INSTDIR\ARM64\vdservice.exe"
RMDir /rebootok "$INSTDIR\ARM64"
RMDir /rebootok /r "$INSTDIR\drivers"
!ifdef OVIRT
Delete /rebootok "$INSTDIR\OVirtGuestService.exe"
Delete /rebootok "$INSTDIR\default.ini"
Delete /rebootok "$INSTDIR\default-logger.ini"
Delete /rebootok "$INSTDIR\ovirt-guest-agent.ini"
Delete /rebootok "$INSTDIR\vcredist_x86.exe"
Delete /rebootok "$INSTDIR\vcredist.arm64.exe"
RMDir /rebootok "$INSTDIR\hooks\after_hibernation"
RMDir /rebootok "$INSTDIR\hooks\before_hibernation"
RMDir /rebootok "$INSTDIR\hooks\after_migration"
RMDir /rebootok "$INSTDIR\hooks\before_migration"
RMDir /rebootok "$INSTDIR\hooks"
!endif
!ifdef SPICE
Delete /rebootok "$INSTDIR\OVirtGuestService.exe"
Delete /rebootok "$INSTDIR\vc_redist.arm64.exe"
Delete /rebootok "$INSTDIR\spice-webdavd-x86-2.2.msi"
Delete /rebootok "$INSTDIR\spice-webdavd-x86-latest.msi"
Delete /rebootok "$INSTDIR\spice-webdavd-x64-2.2.msi"
Delete /rebootok "$INSTDIR\spice-webdavd-x64-latest.msi"
Delete /rebootok "$INSTDIR\spice-webdavd-arm64-latest.msi"
Delete /rebootok "$INSTDIR\qemu-ga-i386.msi"
Delete /rebootok "$INSTDIR\qemu-ga-x86_64.msi"
!endif
RMDir /rebootok "$INSTDIR"
DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${REGKEYNAME}"
SectionEnd
Section -post
WriteUninstaller "$INSTDIR\Uninstall ${FILENAME}.exe"
# for reference: https://stackoverflow.com/questions/2407509/writing-current-date-time-as-file-name-using-nsis
!define /date MyTIMESTAMP "%Y-%m-%d-%H-%M-%S"
StrCpy $0 "$INSTDIR\install-${MyTIMESTAMP}.log"
Push $0
Call DumpLog
SectionEnd
Function .onInit
StrCpy $Enable3D ${BST_UNCHECKED}
${if} ${RunningX64}
${if} ${IsWinXP}
MessageBox MB_ICONEXCLAMATION "Windows XP 64 bit is an unsupported Windows version"
Abort ; causes installer to quit.
${endif}
${endif}
${if} ${AtMostWin2000}
MessageBox MB_ICONEXCLAMATION "Drivers only available for Windows XP or newer"
Abort ; causes installer to quit.
${endif}
FunctionEnd
Function GraphicsPageCreate
!insertmacro MUI_HEADER_TEXT "Graphics Acceleration" "Choose which VirtIO graphics driver to install."
nsDialogs::Create 1018
Pop $GraphicsDialog
${If} $GraphicsDialog == error
Abort
${EndIf}
# Negative coordinates and sizes are relative to the bottom edge, so the
# description soaks up whatever room the controls below it leave
${NSD_CreateLabel} 0 0u 100% -64u "The experimental graphics driver adds hardware 3D acceleration, but it is still under active development. It can cause rendering glitches, application crashes, or a blank display, and should not be used on a machine you rely on.$\r$\n$\r$\nIt also only works on versions of UTM that support 3D acceleration. On any older version the display will not work at all.$\r$\n$\r$\nLeave this unchecked to install the stable display-only driver."
Pop $0
${NSD_CreateLabel} 0 -60u 100% 24u "Note: any existing graphics driver must be uninstalled before the driver installed here can be loaded."
Pop $0
${NSD_CreateCheckbox} 0 -30u 100% 12u "Enable experimental 3D acceleration"
Pop $Enable3DCheckbox
${If} $Enable3D == ${BST_CHECKED}
${NSD_Check} $Enable3DCheckbox
${EndIf}
# viogpu3d is only shipped for Windows 11 amd64 and ARM64
${IfNot} ${AtLeastWin11}
${OrIfNot} ${RunningX64}
${NSD_Uncheck} $Enable3DCheckbox
EnableWindow $Enable3DCheckbox 0
${NSD_CreateLabel} 14u -14u 100% 10u "The experimental driver is not available for this version of Windows."
Pop $0
${EndIf}
nsDialogs::Show
FunctionEnd
Function GraphicsPageLeave
${NSD_GetState} $Enable3DCheckbox $Enable3D
FunctionEnd
Function GetDriverSubdir
Pop $0
${If} ${IsWinXP}
StrCpy $0 "$0\xp"
${ElseIf} ${IsWinVista}
StrCpy $0 "$0\vista"
${ElseIf} ${IsWin2003}
StrCpy $0 "$0\2k3"
${ElseIf} ${IsWin7}
StrCpy $0 "$0\w7"
${ElseIf} ${IsWin2008}
StrCpy $0 "$0\2k8"
${ElseIf} ${IsWin2008R2}
StrCpy $0 "$0\2k8R2"
${ElseIf} ${IsWin8}
StrCpy $0 "$0\w8"
${ElseIf} ${IsWin2012}
StrCpy $0 "$0\2k12"
${ElseIf} ${IsWin8.1}
StrCpy $0 "$0\w8.1"
${ElseIf} ${IsWin2012R2}
StrCpy $0 "$0\2k12r2"
${ElseIf} ${AtLeastWin11}
StrCpy $0 "$0\w11"
${ElseIf} ${AtLeastWin10}
StrCpy $0 "$0\w10"
${ElseIf} ${AtLeastWin2016}
StrCpy $0 "$0\2k16"
${Else}
MessageBox MB_ICONEXCLAMATION "Unsupported Windows version"
Abort ; causes installer to quit.
${EndIf}
${If} ${IsNativeARM64}
StrCpy $0 "$0\ARM64"
${ElseIf} ${IsNativeAMD64}
StrCpy $0 "$0\amd64"
${Else}
StrCpy $0 "$0\x86"
${EndIf}
Push $0
FunctionEnd
Function InstallBalloonDriver
Call InstallDriver
Call InstallBalloonService
FunctionEnd
Function InstallDriver
Pop $R0 ; HID
Pop $R1 ; driver name
Pop $R2 ; driver path
Push $R2
Call GetDriverSubdir
Pop $0
StrCpy $1 $R1
Push $1
StrCpy $2 "$INSTDIR\drivers\$0"
Push $2
StrCpy $3 "$2\$R1.inf"
Push $3
Push $R0
DetailPrint "Installing $R1.inf"
Call InstallUpgradeDriver
FunctionEnd
!macro StopServices un
Function ${un}StopService
pop $R0
SimpleSC::ServiceIsRunning $R0
pop $0
pop $1
${if} $0 != 0
# error
Return
${endif}
${if} $1 == 0
# service not running
Return
${endif}
DetailPrint "Stopping $R0"
SimpleSC::StopService $R0 1 30
pop $0
${if} $0 != 0
DetailPrint "Failed to stop $R0: $0"
Return
${endif}
DetailPrint "$R0 stopped"
FunctionEnd
Function ${un}StopServices
push "vdservice"
Call ${un}StopService
push "BalloonService"
Call ${un}StopService
!ifdef OVIRT
push "OVirtGuestService"
Call ${un}StopService
!endif
FunctionEnd
!macroend
!insertmacro StopServices ""
!insertmacro StopServices "un."
Function un.UninstallService
pop $R0
SimpleSC::ExistsService $R0
Pop $0
${if} $0 == 0
SimpleSC::RemoveService $R0
${endif}
FunctionEnd
Function un.UninstallServices
push "vdservice"
Call un.UninstallService
push "BalloonService"
Call un.UninstallService
!ifdef OVIRT
push "OVirtGuestService"
Call un.UninstallService
!endif
FunctionEnd
Function InstallService
pop $R0 #service name
pop $R1 #service path
pop $R2 #service pretty name
SimpleSC::ExistsService $R0
Pop $0
${if} $0 == 0
DetailPrint "$R2 service already installed"
goto InstallService
${endif}
DetailPrint "Installing $R2 service"
SimpleSC::InstallService $R0 $R2 16 2 '"$R1"' "" "" ""
Pop $0
${if} $0 != 0
DetailPrint "Failed to install $R2 service: $0"
Return
${endif}
DetailPrint "$R2 service installed"
InstallService:
DetailPrint "Starting $R2 service"
SimpleSC::StartService $R0 "" 30
Pop $0
${if} $0 != 0
DetailPrint "Failed to start $R2 service: $0"
Return
${endif}
DetailPrint "$R2 service started"
FunctionEnd
Function InstallQemuGuestAgent
${if} ${IsNativeAMD64}
StrCpy $0 "$INSTDIR\drivers\guest-agent\qemu-ga-x64.msi"
${else}
StrCpy $0 "$INSTDIR\drivers\guest-agent\qemu-ga-x86.msi"
${endif}
ExecWait '"msiexec.exe" /qn /i "$0"'
FunctionEnd
Function un.UninstallQemuGuestAgent
${if} ${IsNativeAMD64}
StrCpy $0 "$INSTDIR\drivers\guest-agent\qemu-ga-x64.msi"
${else}
StrCpy $0 "$INSTDIR\drivers\guest-agent\qemu-ga-x86.msi"
${endif}
ExecWait '"msiexec.exe" /qn /x "$0"'
FunctionEnd
Function InstallVdAgentService
${if} ${IsNativeARM64}
StrCpy $0 "$INSTDIR\ARM64\vdservice.exe"
${elseif} ${IsNativeAMD64}
StrCpy $0 "$INSTDIR\64\vdservice.exe"
${else}
StrCpy $0 "$INSTDIR\32\vdservice.exe"
${endif}
push "SPICE VDAgent"
push $0
push "vdservice"
Call InstallService
FunctionEnd
!ifdef OVIRT
Function InstallOVirtAgentService
StrCpy $0 "$INSTDIR\OVirtGuestService.exe"
push "OVirt Guest Service"
push $0
push "OVirtGuestService"
Call InstallService
FunctionEnd
!endif
!ifdef SPICE
Function InstallSpiceWebdavd
${if} ${IsNativeARM64}
StrCpy $0 "$INSTDIR\spice-webdavd-arm64-latest.msi"
${elseif} ${IsNativeAMD64}
${if} ${AtLeastWin7}
StrCpy $0 "$INSTDIR\spice-webdavd-x64-latest.msi"
${else}
StrCpy $0 "$INSTDIR\spice-webdavd-x64-2.2.msi"
${endif}
${else}
${if} ${AtLeastWin7}
StrCpy $0 "$INSTDIR\spice-webdavd-x86-latest.msi"
${else}
StrCpy $0 "$INSTDIR\spice-webdavd-x86-2.2.msi"
${endif}
${endif}
ExecWait '"msiexec.exe" /qn /i "$0"'
FunctionEnd
Function un.UninstallSpiceWebdavd
${if} ${IsNativeARM64}
StrCpy $0 "$INSTDIR\spice-webdavd-arm64-latest.msi"
${elseif} ${IsNativeAMD64}
${if} ${AtLeastWin7}
StrCpy $0 "$INSTDIR\spice-webdavd-x64-latest.msi"
${else}
StrCpy $0 "$INSTDIR\spice-webdavd-x64-2.2.msi"
${endif}
${else}
${if} ${AtLeastWin7}
StrCpy $0 "$INSTDIR\spice-webdavd-x86-latest.msi"
${else}
StrCpy $0 "$INSTDIR\spice-webdavd-x86-2.2.msi"
${endif}
${endif}
ExecWait '"msiexec.exe" /qn /x "$0"'
FunctionEnd
Function InstallGuestAgent
${if} ${IsNativeARM64}
StrCpy $0 "$INSTDIR\qemu-ga-x86_64.msi"
${elseif} ${IsNativeAMD64}
StrCpy $0 "$INSTDIR\qemu-ga-x86_64.msi"
${else}
StrCpy $0 "$INSTDIR\qemu-ga-i386.msi"
${endif}
ExecWait '"msiexec.exe" /qn /i "$0"'
FunctionEnd
Function un.UninstallGuestAgent
${if} ${IsNativeARM64}
StrCpy $0 "$INSTDIR\qemu-ga-x86_64.msi"
${elseif} ${IsNativeAMD64}
StrCpy $0 "$INSTDIR\qemu-ga-x86_64.msi"
${else}
StrCpy $0 "$INSTDIR\qemu-ga-i386.msi"
${endif}
ExecWait '"msiexec.exe" /qn /x "$0"'
FunctionEnd
!endif
Function InstallBalloonService
Push "Balloon"
Call GetDriverSubdir
Pop $0
StrCpy $0 "$INSTDIR\drivers\$0\blnsvr.exe"
Push "Balloon Service"
Push $0
Push "BalloonService"
Call InstallService
FunctionEnd
Function DisableFallbackDisplay
DetailPrint "Disabling firmware display adapter"
WriteRegDWORD HKLM "System\CurrentControlSet\Control\GraphicsDrivers\BasicDisplay" \
"DisableBasicDisplayFallback" "1"
SetRebootFlag true
FunctionEnd
Function un.EnableFallbackDisplay
DetailPrint "Enabling firmware display adapter"
DeleteRegValue HKLM "System\CurrentControlSet\Control\GraphicsDrivers\BasicDisplay" \
"DisableBasicDisplayFallback"
DeleteRegKey /ifempty HKLM "System\CurrentControlSet\Control\GraphicsDrivers\BasicDisplay"
SetRebootFlag true
FunctionEnd