VirtualBox

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

Last change on this file since 34079 was 33970, checked in by vboxsync, 14 years ago

Windows Guest Additions installer: Added command line switch "/no_vboxtray_exit" to prevent VBoxTray being shut down during a Guest Additions update.

  • 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 ${If} $g_bNoVBoxTrayExit == "false"
82 ; Stop / kill VBoxTray
83 Call StopVBoxTray
84 ${EndIf}
85
86 ; Delete VBoxService from registry
87 DeleteRegValue HKLM "Software\Microsoft\Windows\CurrentVersion\Run" "VBoxService"
88
89 ; Delete old VBoxService.exe from install directory (replaced by VBoxTray.exe)
90 Delete /REBOOTOK "$INSTDIR\VBoxService.exe"
91
92FunctionEnd
93
94Function NT_CopyFiles
95
96 DetailPrint "Copying files..."
97
98 SetOutPath "$INSTDIR"
99 FILE "$%PATH_OUT%\bin\additions\VBoxGuestDrvInst.exe"
100 FILE "$%PATH_OUT%\bin\additions\RegCleanup.exe"
101
102 ; The files to install for NT 4, they go into the system directories
103 SetOutPath "$SYSDIR"
104 FILE "$%PATH_OUT%\bin\additions\VBoxDisp.dll"
105 FILE "$%PATH_OUT%\bin\additions\VBoxTray.exe"
106 FILE "$%PATH_OUT%\bin\additions\VBoxHook.dll"
107 FILE "$%PATH_OUT%\bin\additions\VBoxControl.exe"
108
109 ; VBoxService
110 FILE "$%PATH_OUT%\bin\additions\VBoxServiceNT.exe"
111
112 ; The drivers into the "drivers" directory
113 SetOutPath "$SYSDIR\drivers"
114 FILE "$%PATH_OUT%\bin\additions\VBoxVideo.sys"
115 FILE "$%PATH_OUT%\bin\additions\VBoxMouseNT.sys"
116 FILE "$%PATH_OUT%\bin\additions\VBoxGuestNT.sys"
117 ;FILE "$%PATH_OUT%\bin\additions\VBoxSFNT.sys" ; Shared Folders not available on NT4!
118
119FunctionEnd
120
121Function NT_InstallFiles
122
123 DetailPrint "Installing Drivers..."
124
125 ; Install guest driver
126 nsExec::ExecToLog '"$INSTDIR\VBoxDrvInst.exe" /createsvc "VBoxGuest" "VBoxGuest Support Driver" 1 1 "$SYSDIR\drivers\VBoxGuestNT.sys" "Base"'
127
128 ; Bugfix: Set "Start" to 1, otherwise, VBoxGuest won't start on boot-up!
129 ; Bugfix: Correct invalid "ImagePath" (\??\C:\WINNT\...)
130 WriteRegDWORD HKLM "SYSTEM\CurrentControlSet\Services\VBoxGuest" "Start" 1
131 WriteRegStr HKLM "SYSTEM\CurrentControlSet\Services\VBoxGuest" "ImagePath" "System32\Drivers\VBoxGuestNT.sys"
132
133 ; Run VBoxTray when Windows NT starts
134 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Run" "VBoxTray" '"$SYSDIR\VBoxTray.exe"'
135
136 ; Video driver
137 nsExec::ExecToLog '"$INSTDIR\VBoxGuestDrvInst.exe" /i'
138 Pop $0 ; Ret value
139 IntCmp $0 0 +1 error error ; Check ret value (0=OK, 1=Error)
140
141 DetailPrint "Installing VirtualBox service ..."
142
143 ; Create the VBoxService service
144 ; No need to stop/remove the service here! Do this only on uninstallation!
145 nsExec::ExecToLog '"$INSTDIR\VBoxDrvInst.exe" /createsvc "VBoxService" "VirtualBox Guest Additions Service" 16 2 "system32\VBoxServiceNT.exe" "Base"'
146
147 ; Create the Shared Folders service ...
148 ;nsSCM::Install /NOUNLOAD "VBoxSF" "VirtualBox Shared Folders" 1 1 "$SYSDIR\drivers\VBoxSFNT.sys" "Network" "" "" ""
149 ;Pop $0 ; Ret value
150
151!ifdef _DEBUG
152 ;DetailPrint "SCM::Install VBoxSFNT.sys: $0"
153!endif
154
155 ;IntCmp $0 0 +1 error error ; Check ret value (0=OK, 1=Error)
156
157 ; ... and the link to the network provider
158 ;WriteRegStr HKLM "SYSTEM\CurrentControlSet\Services\VBoxSF\NetworkProvider" "DeviceName" "\Device\VBoxMiniRdr"
159 ;WriteRegStr HKLM "SYSTEM\CurrentControlSet\Services\VBoxSF\NetworkProvider" "Name" "VirtualBox Shared Folders"
160 ;WriteRegStr HKLM "SYSTEM\CurrentControlSet\Services\VBoxSF\NetworkProvider" "ProviderPath" "$SYSDIR\VBoxMRXNP.dll"
161
162 ; Add the shared folders network provider
163 ;nsExec::ExecToLog '"$INSTDIR\VBoxDrvInst.exe" /addnetprovider VBoxSF'
164 ;Pop $0 ; Ret value
165
166!ifdef _DEBUG
167 ;DetailPrint "VBoxDrvInst::AddProvider VBoxSF: $0"
168!endif
169
170 ;IntCmp $0 0 +1 error error ; Check ret value (0=OK, 1=Error)
171
172 Goto done
173
174error:
175 Abort "ERROR: Could not install files for Windows NT! Installation aborted."
176
177done:
178
179FunctionEnd
180
181Function NT_Main
182
183 SetOutPath "$INSTDIR"
184
185 Call NT_Prepare
186 Call NT_CopyFiles
187
188 ; This removes the flag "new display driver installed on the next bootup
189 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\RunOnce" "VBoxGuestInst" '"$INSTDIR\RegCleanup.exe"'
190
191 Call NT_SaveMouseDriverInfo
192 Call NT_InstallFiles
193 Call NT_SetVideoResolution
194
195 ; Write mouse driver name to registry overwriting the default name
196 WriteRegStr HKLM "SYSTEM\CurrentControlSet\Services\i8042prt" "ImagePath" "System32\DRIVERS\VBoxMouseNT.sys"
197
198FunctionEnd
199
200!macro NT_UninstallInstDir un
201Function ${un}NT_UninstallInstDir
202
203 ; Delete remaining files
204 Delete /REBOOTOK "$INSTDIR\VBoxGuestDrvInst.exe"
205 Delete /REBOOTOK "$INSTDIR\RegCleanup.exe"
206
207FunctionEnd
208!macroend
209!insertmacro NT_UninstallInstDir ""
210!insertmacro NT_UninstallInstDir "un."
211
212!macro NT_Uninstall un
213Function ${un}NT_Uninstall
214
215 Push $0
216
217 ; Remove the guest driver service
218 nsExec::ExecToLog '"$INSTDIR\VBoxDrvInst.exe" /delsvc VBoxGuest'
219 Delete /REBOOTOK "$SYSDIR\drivers\VBoxGuestNT.sys"
220
221 ; Delete the VBoxService service
222 Call ${un}StopVBoxService
223 nsExec::ExecToLog '"$INSTDIR\VBoxDrvInst.exe" /delsvc VBoxService'
224 Pop $0 ; Ret value
225 DeleteRegValue HKLM "Software\Microsoft\Windows\CurrentVersion\Run" "VBoxService"
226 Delete /REBOOTOK "$SYSDIR\VBoxServiceNT.exe"
227
228 ; Delete the VBoxTray app
229 Call ${un}StopVBoxTray
230 DeleteRegValue HKLM "Software\Microsoft\Windows\CurrentVersion\Run" "VBoxTray"
231 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\RunOnce" "VBoxTrayDel" "$SYSDIR\cmd.exe /c del /F /Q $SYSDIR\VBoxTray.exe"
232 Delete /REBOOTOK "$SYSDIR\VBoxTray.exe" ; If it can't be removed cause it's running, try next boot with "RunOnce" key above!
233 Delete /REBOOTOK "$SYSDIR\VBoxHook.dll"
234
235 ; Delete the VBoxControl utility
236 Delete /REBOOTOK "$SYSDIR\VBoxControl.exe"
237
238 ; Delete the VBoxVideo service
239 nsExec::ExecToLog '"$INSTDIR\VBoxDrvInst.exe" /delsvc VBoxVideo'
240
241 ; Delete the VBox video driver files
242 Delete /REBOOTOK "$SYSDIR\drivers\VBoxVideo.sys"
243 Delete /REBOOTOK "$SYSDIR\VBoxDisp.dll"
244
245 ; Get original mouse driver info and restore it
246 ReadRegStr $0 ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" ${ORG_MOUSE_PATH}
247 ; If we still got our driver stored in $0 then this will *never* work, so
248 ; warn the user and set it to the default driver to not screw up NT4 here
249 ${If} $0 == "System32\DRIVERS\VBoxMouseNT.sys"
250 WriteRegStr HKLM "SYSTEM\CurrentControlSet\Services\i8042prt" "ImagePath" "System32\DRIVERS\i8042prt.sys"
251 DetailPrint "Old mouse driver is set to VBoxMouseNT.sys, defaulting to i8042prt.sys ..."
252 ${Else}
253 WriteRegStr HKLM "SYSTEM\CurrentControlSet\Services\i8042prt" "ImagePath" $0
254 ${EndIf}
255 Delete /REBOOTOK "$SYSDIR\drivers\VBoxMouseNT.sys"
256
257 Pop $0
258
259FunctionEnd
260!macroend
261!insertmacro NT_Uninstall ""
262!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