VirtualBox

source: vbox/trunk/src/VBox/Additions/WINNT/Installer/VBoxGuestAdditionsNT4.nsh@ 33280

Last change on this file since 33280 was 33087, checked in by vboxsync, 14 years ago

Windows Guest Additions installer: Added switch for not shutting down VBoxService when installing, ignore unknown command line parameters in silent mode.

  • Property svn:eol-style set to native
File size: 9.4 KB
Line 
1
2Function NT_SetVideoResolution
3
4 ; Check for all required parameters
5 StrCmp $g_iScreenX "0" missingParms
6 StrCmp $g_iScreenY "0" missingParms
7 StrCmp $g_iScreenBpp "0" missingParms
8 Goto haveParms
9
10missingParms:
11
12 DetailPrint "Missing display parameters for NT, setting default (640x480, 8 BPP) ..."
13
14 StrCpy $g_iScreenX '640' ; Default value
15 StrCpy $g_iScreenY '480' ; Default value
16 StrCpy $g_iScreenBpp '8' ; Default value
17
18 ; Write setting into registry to show the desktop applet on next boot
19 WriteRegStr HKLM "SYSTEM\CurrentControlSet\Control\GraphicsDrivers\NewDisplay" "" ""
20
21haveParms:
22
23 DetailPrint "Setting display parameters for NT ($g_iScreenXx$g_iScreenY, $g_iScreenBpp BPP) ..."
24
25 WriteRegDWORD HKLM "SYSTEM\CurrentControlSet\Hardware Profiles\Current\System\CurrentControlSet\Services\vboxvideo\Device0" "DefaultSettings.BitsPerPel" $g_iScreenBpp
26 WriteRegDWORD HKLM "SYSTEM\CurrentControlSet\Hardware Profiles\Current\System\CurrentControlSet\Services\vboxvideo\Device0" "DefaultSettings.Flags" 0x00000000
27 WriteRegDWORD HKLM "SYSTEM\CurrentControlSet\Hardware Profiles\Current\System\CurrentControlSet\Services\vboxvideo\Device0" "DefaultSettings.VRefresh" 0x00000001
28 WriteRegDWORD HKLM "SYSTEM\CurrentControlSet\Hardware Profiles\Current\System\CurrentControlSet\Services\vboxvideo\Device0" "DefaultSettings.XPanning" 0x00000000
29 WriteRegDWORD HKLM "SYSTEM\CurrentControlSet\Hardware Profiles\Current\System\CurrentControlSet\Services\vboxvideo\Device0" "DefaultSettings.XResolution" $g_iScreenX
30 WriteRegDWORD HKLM "SYSTEM\CurrentControlSet\Hardware Profiles\Current\System\CurrentControlSet\Services\vboxvideo\Device0" "DefaultSettings.YPanning" 0x00000000
31 WriteRegDWORD HKLM "SYSTEM\CurrentControlSet\Hardware Profiles\Current\System\CurrentControlSet\Services\vboxvideo\Device0" "DefaultSettings.YResolution" $g_iScreenY
32
33FunctionEnd
34
35Function NT_SaveMouseDriverInfo
36
37 Push $0
38
39 ; !!! NOTE !!!
40 ; Due to some re-branding (see functions Uninstall_Sun, Uninstall_Innotek and
41 ; Uninstall_SunXVM) the installer *has* to transport the very first saved i8042prt
42 ; value to the current installer's "uninstall" directory in both mentioned
43 ; functions above, otherwise NT4 will be screwed because it then would store
44 ; "VBoxMouseNT.sys" as the original i8042prt driver which obviously isn't there
45 ; after uninstallation anymore.
46 ; !!! NOTE !!!
47
48 ; Save current mouse driver info so we may restore it on uninstallation
49 ; But first check if we already installed the additions otherwise we will
50 ; overwrite it with the VBoxMouseNT.sys
51 ReadRegStr $0 HKLM "${PRODUCT_UNINST_KEY}" ${ORG_MOUSE_PATH}
52 StrCmp $0 "" 0 exists
53
54 DetailPrint "Saving mouse driver info ..."
55 ReadRegStr $0 HKLM "SYSTEM\CurrentControlSet\Services\i8042prt" "ImagePath"
56 WriteRegStr HKLM "${PRODUCT_UNINST_KEY}" ${ORG_MOUSE_PATH} $0
57 Goto exit
58
59exists:
60
61 DetailPrint "Mouse driver info already saved."
62 Goto exit
63
64exit:
65
66!ifdef _DEBUG
67 DetailPrint "Mouse driver info: $0"
68!endif
69
70 Pop $0
71
72FunctionEnd
73
74Function NT_Prepare
75
76 ${If} $g_bNoVBoxServiceExit == "false"
77 ; Stop / kill VBoxService
78 Call StopVBoxService
79 ${EndIf}
80
81 ; Stop / kill VBoxTray
82 Call StopVBoxTray
83
84 ; Delete VBoxService from registry
85 DeleteRegValue HKLM "Software\Microsoft\Windows\CurrentVersion\Run" "VBoxService"
86
87 ; Delete old VBoxService.exe from install directory (replaced by VBoxTray.exe)
88 Delete /REBOOTOK "$INSTDIR\VBoxService.exe"
89
90FunctionEnd
91
92Function NT_CopyFiles
93
94 DetailPrint "Copying files..."
95
96 SetOutPath "$INSTDIR"
97 FILE "$%PATH_OUT%\bin\additions\VBoxGuestDrvInst.exe"
98 FILE "$%PATH_OUT%\bin\additions\RegCleanup.exe"
99
100 ; The files to install for NT 4, they go into the system directories
101 SetOutPath "$SYSDIR"
102 FILE "$%PATH_OUT%\bin\additions\VBoxDisp.dll"
103 FILE "$%PATH_OUT%\bin\additions\VBoxTray.exe"
104 FILE "$%PATH_OUT%\bin\additions\VBoxHook.dll"
105 FILE "$%PATH_OUT%\bin\additions\VBoxControl.exe"
106
107 ; VBoxService
108 FILE "$%PATH_OUT%\bin\additions\VBoxServiceNT.exe"
109
110 ; The drivers into the "drivers" directory
111 SetOutPath "$SYSDIR\drivers"
112 FILE "$%PATH_OUT%\bin\additions\VBoxVideo.sys"
113 FILE "$%PATH_OUT%\bin\additions\VBoxMouseNT.sys"
114 FILE "$%PATH_OUT%\bin\additions\VBoxGuestNT.sys"
115 ;FILE "$%PATH_OUT%\bin\additions\VBoxSFNT.sys" ; Shared Folders not available on NT4!
116
117FunctionEnd
118
119Function NT_InstallFiles
120
121 DetailPrint "Installing Drivers..."
122
123 ; Install guest driver
124 nsExec::ExecToLog '"$INSTDIR\VBoxDrvInst.exe" /createsvc "VBoxGuest" "VBoxGuest Support Driver" 1 1 "$SYSDIR\drivers\VBoxGuestNT.sys" "Base"'
125
126 ; Bugfix: Set "Start" to 1, otherwise, VBoxGuest won't start on boot-up!
127 ; Bugfix: Correct invalid "ImagePath" (\??\C:\WINNT\...)
128 WriteRegDWORD HKLM "SYSTEM\CurrentControlSet\Services\VBoxGuest" "Start" 1
129 WriteRegStr HKLM "SYSTEM\CurrentControlSet\Services\VBoxGuest" "ImagePath" "System32\Drivers\VBoxGuestNT.sys"
130
131 ; Run VBoxTray when Windows NT starts
132 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Run" "VBoxTray" '"$SYSDIR\VBoxTray.exe"'
133
134 ; Video driver
135 nsExec::ExecToLog '"$INSTDIR\VBoxGuestDrvInst.exe" /i'
136 Pop $0 ; Ret value
137 IntCmp $0 0 +1 error error ; Check ret value (0=OK, 1=Error)
138
139 DetailPrint "Installing VirtualBox service ..."
140
141 ; Create the VBoxService service
142 ; No need to stop/remove the service here! Do this only on uninstallation!
143 nsExec::ExecToLog '"$INSTDIR\VBoxDrvInst.exe" /createsvc "VBoxService" "VirtualBox Guest Additions Service" 16 2 "system32\VBoxServiceNT.exe" "Base"'
144
145 ; Create the Shared Folders service ...
146 ;nsSCM::Install /NOUNLOAD "VBoxSF" "VirtualBox Shared Folders" 1 1 "$SYSDIR\drivers\VBoxSFNT.sys" "Network" "" "" ""
147 ;Pop $0 ; Ret value
148
149!ifdef _DEBUG
150 ;DetailPrint "SCM::Install VBoxSFNT.sys: $0"
151!endif
152
153 ;IntCmp $0 0 +1 error error ; Check ret value (0=OK, 1=Error)
154
155 ; ... and the link to the network provider
156 ;WriteRegStr HKLM "SYSTEM\CurrentControlSet\Services\VBoxSF\NetworkProvider" "DeviceName" "\Device\VBoxMiniRdr"
157 ;WriteRegStr HKLM "SYSTEM\CurrentControlSet\Services\VBoxSF\NetworkProvider" "Name" "VirtualBox Shared Folders"
158 ;WriteRegStr HKLM "SYSTEM\CurrentControlSet\Services\VBoxSF\NetworkProvider" "ProviderPath" "$SYSDIR\VBoxMRXNP.dll"
159
160 ; Add the shared folders network provider
161 ;nsExec::ExecToLog '"$INSTDIR\VBoxDrvInst.exe" /addnetprovider VBoxSF'
162 ;Pop $0 ; Ret value
163
164!ifdef _DEBUG
165 ;DetailPrint "VBoxDrvInst::AddProvider VBoxSF: $0"
166!endif
167
168 ;IntCmp $0 0 +1 error error ; Check ret value (0=OK, 1=Error)
169
170 Goto done
171
172error:
173 Abort "ERROR: Could not install files for Windows NT! Installation aborted."
174
175done:
176
177FunctionEnd
178
179Function NT_Main
180
181 SetOutPath "$INSTDIR"
182
183 Call NT_Prepare
184 Call NT_CopyFiles
185
186 ; This removes the flag "new display driver installed on the next bootup
187 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\RunOnce" "VBoxGuestInst" '"$INSTDIR\RegCleanup.exe"'
188
189 Call NT_SaveMouseDriverInfo
190 Call NT_InstallFiles
191 Call NT_SetVideoResolution
192
193 ; Write mouse driver name to registry overwriting the default name
194 WriteRegStr HKLM "SYSTEM\CurrentControlSet\Services\i8042prt" "ImagePath" "System32\DRIVERS\VBoxMouseNT.sys"
195
196FunctionEnd
197
198!macro NT_UninstallInstDir un
199Function ${un}NT_UninstallInstDir
200
201 ; Delete remaining files
202 Delete /REBOOTOK "$INSTDIR\VBoxGuestDrvInst.exe"
203 Delete /REBOOTOK "$INSTDIR\RegCleanup.exe"
204
205FunctionEnd
206!macroend
207!insertmacro NT_UninstallInstDir ""
208!insertmacro NT_UninstallInstDir "un."
209
210!macro NT_Uninstall un
211Function ${un}NT_Uninstall
212
213 Push $0
214
215 ; Remove the guest driver service
216 nsExec::ExecToLog '"$INSTDIR\VBoxDrvInst.exe" /delsvc VBoxGuest'
217 Delete /REBOOTOK "$SYSDIR\drivers\VBoxGuestNT.sys"
218
219 ; Delete the VBoxService service
220 Call ${un}StopVBoxService
221 nsExec::ExecToLog '"$INSTDIR\VBoxDrvInst.exe" /delsvc VBoxService'
222 Pop $0 ; Ret value
223 DeleteRegValue HKLM "Software\Microsoft\Windows\CurrentVersion\Run" "VBoxService"
224 Delete /REBOOTOK "$SYSDIR\VBoxServiceNT.exe"
225
226 ; Delete the VBoxTray app
227 Call ${un}StopVBoxTray
228 DeleteRegValue HKLM "Software\Microsoft\Windows\CurrentVersion\Run" "VBoxTray"
229 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\RunOnce" "VBoxTrayDel" "$SYSDIR\cmd.exe /c del /F /Q $SYSDIR\VBoxTray.exe"
230 Delete /REBOOTOK "$SYSDIR\VBoxTray.exe" ; If it can't be removed cause it's running, try next boot with "RunOnce" key above!
231 Delete /REBOOTOK "$SYSDIR\VBoxHook.dll"
232
233 ; Delete the VBoxControl utility
234 Delete /REBOOTOK "$SYSDIR\VBoxControl.exe"
235
236 ; Delete the VBoxVideo service
237 nsExec::ExecToLog '"$INSTDIR\VBoxDrvInst.exe" /delsvc VBoxVideo'
238
239 ; Delete the VBox video driver files
240 Delete /REBOOTOK "$SYSDIR\drivers\VBoxVideo.sys"
241 Delete /REBOOTOK "$SYSDIR\VBoxDisp.dll"
242
243 ; Get original mouse driver info and restore it
244 ReadRegStr $0 ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" ${ORG_MOUSE_PATH}
245 ; If we still got our driver stored in $0 then this will *never* work, so
246 ; warn the user and set it to the default driver to not screw up NT4 here
247 ${If} $0 == "System32\DRIVERS\VBoxMouseNT.sys"
248 WriteRegStr HKLM "SYSTEM\CurrentControlSet\Services\i8042prt" "ImagePath" "System32\DRIVERS\i8042prt.sys"
249 DetailPrint "Old mouse driver is set to VBoxMouseNT.sys, defaulting to i8042prt.sys ..."
250 ${Else}
251 WriteRegStr HKLM "SYSTEM\CurrentControlSet\Services\i8042prt" "ImagePath" $0
252 ${EndIf}
253 Delete /REBOOTOK "$SYSDIR\drivers\VBoxMouseNT.sys"
254
255 Pop $0
256
257FunctionEnd
258!macroend
259!insertmacro NT_Uninstall ""
260!insertmacro NT_Uninstall "un."
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette