VirtualBox

source: vbox/trunk/src/VBox/Main/src-all/win/comregister.cmd@ 59385

Last change on this file since 59385 was 59385, checked in by vboxsync, 9 years ago

VBoxProxyStub,comregister,glue: Added a second proxy dll for older 64-bit windows versions since we're having trouble convincing MIDL to produce code that works with XP64/W2K3 without indicating that we're targetting windows 2000 and dropping the ndr64/all protocol option. Using the legacy proxy stub for vista and windows server 2008 too, since there was some potentially interesting changes introduced with windows 7 that we might benefit from.

  • Property svn:eol-style set to CRLF
  • Property svn:keywords set to Author Date Id Revision
File size: 7.4 KB
Line 
1@echo off
2REM $Id: comregister.cmd 59385 2016-01-18 17:37:59Z vboxsync $
3REM
4REM Script to register the VirtualBox COM classes
5REM (both inproc and out-of-process)
6REM
7
8REM
9REM Copyright (C) 2006-2016 Oracle Corporation
10REM
11REM This file is part of VirtualBox Open Source Edition (OSE), as
12REM available from http://www.virtualbox.org. This file is free software;
13REM you can redistribute it and/or modify it under the terms of the GNU
14REM General Public License (GPL) as published by the Free Software
15REM Foundation, in version 2 as it comes in the "COPYING" file of the
16REM VirtualBox OSE distribution. VirtualBox OSE is distributed in the
17REM hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
18REM
19
20setlocal
21
22REM Check if the current user is an administrator. Otherwise
23REM all the COM registration will fail silently.
24NET FILE 1>NUL 2>NUL & IF ERRORLEVEL 1 (ECHO Must be run as Administrator. Exiting.) & GOTO end
25
26REM
27REM Figure out where the script lives first, so that we can invoke the
28REM correct VBoxSVC and register the right VBoxC.dll.
29REM
30
31REM Determine the current directory.
32set _SCRIPT_CURDIR=%CD%
33for /f "tokens=*" %%d in ('cd') do set _SCRIPT_CURDIR=%%d
34
35REM Determine a correct self - by %0.
36set _SCRIPT_SELF=%0
37if exist "%_SCRIPT_SELF%" goto found_self
38set _SCRIPT_SELF=%_SCRIPT_SELF%.cmd
39if exist "%_SCRIPT_SELF%" goto found_self
40
41REM Determine a correct self - by current working directory.
42set _SCRIPT_SELF=%_SCRIPT_CURDIR%\comregister.cmd
43if exist "%_SCRIPT_SELF%" goto found_self
44
45REM Determine a correct self - by the PATH
46REM This is very verbose because nested for loops didn't work out.
47for /f "tokens=1 delims=;" %%d in ("%PATH%") do set _SCRIPT_SELF=%%d\comregister.cmd
48if exist "%_SCRIPT_SELF%" goto found_self
49for /f "tokens=2 delims=;" %%d in ("%PATH%") do set _SCRIPT_SELF=%%d\comregister.cmd
50if exist "%_SCRIPT_SELF%" goto found_self
51for /f "tokens=3 delims=;" %%d in ("%PATH%") do set _SCRIPT_SELF=%%d\comregister.cmd
52if exist "%_SCRIPT_SELF%" goto found_self
53for /f "tokens=4 delims=;" %%d in ("%PATH%") do set _SCRIPT_SELF=%%d\comregister.cmd
54if exist "%_SCRIPT_SELF%" goto found_self
55for /f "tokens=5 delims=;" %%d in ("%PATH%") do set _SCRIPT_SELF=%%d\comregister.cmd
56if exist "%_SCRIPT_SELF%" goto found_self
57for /f "tokens=6 delims=;" %%d in ("%PATH%") do set _SCRIPT_SELF=%%d\comregister.cmd
58if exist "%_SCRIPT_SELF%" goto found_self
59for /f "tokens=7 delims=;" %%d in ("%PATH%") do set _SCRIPT_SELF=%%d\comregister.cmd
60if exist "%_SCRIPT_SELF%" goto found_self
61for /f "tokens=8 delims=;" %%d in ("%PATH%") do set _SCRIPT_SELF=%%d\comregister.cmd
62if exist "%_SCRIPT_SELF%" goto found_self
63for /f "tokens=9 delims=;" %%d in ("%PATH%") do set _SCRIPT_SELF=%%d\comregister.cmd
64if exist "%_SCRIPT_SELF%" goto found_self
65for /f "tokens=10 delims=;" %%d in ("%PATH%") do set _SCRIPT_SELF=%%d\comregister.cmd
66if exist "%_SCRIPT_SELF%" goto found_self
67for /f "tokens=11 delims=;" %%d in ("%PATH%") do set _SCRIPT_SELF=%%d\comregister.cmd
68if exist "%_SCRIPT_SELF%" goto found_self
69for /f "tokens=12 delims=;" %%d in ("%PATH%") do set _SCRIPT_SELF=%%d\comregister.cmd
70if exist "%_SCRIPT_SELF%" goto found_self
71for /f "tokens=13 delims=;" %%d in ("%PATH%") do set _SCRIPT_SELF=%%d\comregister.cmd
72if exist "%_SCRIPT_SELF%" goto found_self
73for /f "tokens=14 delims=;" %%d in ("%PATH%") do set _SCRIPT_SELF=%%d\comregister.cmd
74if exist "%_SCRIPT_SELF%" goto found_self
75for /f "tokens=15 delims=;" %%d in ("%PATH%") do set _SCRIPT_SELF=%%d\comregister.cmd
76if exist "%_SCRIPT_SELF%" goto found_self
77for /f "tokens=16 delims=;" %%d in ("%PATH%") do set _SCRIPT_SELF=%%d\comregister.cmd
78if exist "%_SCRIPT_SELF%" goto found_self
79for /f "tokens=17 delims=;" %%d in ("%PATH%") do set _SCRIPT_SELF=%%d\comregister.cmd
80if exist "%_SCRIPT_SELF%" goto found_self
81for /f "tokens=18 delims=;" %%d in ("%PATH%") do set _SCRIPT_SELF=%%d\comregister.cmd
82if exist "%_SCRIPT_SELF%" goto found_self
83for /f "tokens=19 delims=;" %%d in ("%PATH%") do set _SCRIPT_SELF=%%d\comregister.cmd
84if exist "%_SCRIPT_SELF%" goto found_self
85for /f "tokens=20 delims=;" %%d in ("%PATH%") do set _SCRIPT_SELF=%%d\comregister.cmd
86if exist "%_SCRIPT_SELF%" goto found_self
87echo Warning: Not able to determin the comregister.cmd location.
88set _VBOX_DIR=
89goto register
90
91:found_self
92set _VBOX_DIR=
93cd "%_SCRIPT_SELF%\.."
94for /f "tokens=*" %%d in ('cd') do set _VBOX_DIR=%%d\
95cd "%_SCRIPT_CURDIR%"
96
97REM
98REM Check for 64-bitness.
99REM
100set fIs64BitWindows=0
101if not "%ProgramW6432%x" == "x" set fIs64BitWindows=1
102if exist "%windir\syswow64\kernel32.dll" set fIs64BitWindows=1
103
104REM
105REM Figure out the Windows version as the proxy stub requires 6.0 or later (at least for 64-bit).
106REM
107set WinVer=Version 4.0.1381
108set WinVerMajor=4
109set WinVerMinor=0
110set WinVerBuild=1381
111for /f "tokens=2 delims=[]" %%a in ('ver') do set WinVer=%%a
112for /f "tokens=2,3,4 delims=. " %%a in ("%WinVer%") do (
113 set WinVerMajor=%%a
114 set WinVerMinor=%%b
115 set WinVerBuild=%%c
116)
117REM echo WinVerMajor=%WinVerMajor% WinVerMinor=%WinVerMinor% WinVerBuild=%WinVerBuild% WinVer=%WinVer%
118
119REM
120REM Parse arguments.
121REM
122set fNoProxy=0
123set fUninstallOnly=0
124
125:arg_loop
126if "%1x" == "x" goto arg_done
127
128if "%1" == "-u" goto arg_uninstall
129if "%1" == "--uninstall" goto arg_uninstall
130if "%1" == "--proxy" goto arg_proxy
131if "%1" == "--no-proxy" goto arg_no_proxy
132echo syntax error: Unknown option %1
133echo usage: comregister.cmd [-u,--uninstall] [--no-proxy] [--proxy]
134goto end
135
136:arg_uninstall
137set fUninstallOnly=1
138goto arg_next
139
140:arg_proxy
141set fNoProxy=0
142goto arg_next
143
144:arg_no_proxy
145set fNoProxy=1
146goto arg_next
147
148:arg_next
149shift
150goto arg_loop
151:arg_done
152
153REM
154REM Do the registrations.
155REM
156@if %fIs64BitWindows% == 1 goto register_amd64
157
158:register_x86
159@echo on
160"%_VBOX_DIR%VBoxSVC.exe" /UnregServer
161regsvr32 /s /u "%_VBOX_DIR%VBoxC.dll"
162%windir%\system32\regsvr32 /s /u "%_VBOX_DIR%VBoxProxyStub.dll"
163@if %fUninstallOnly% == 1 goto end
164"%_VBOX_DIR%VBoxSVC.exe" /RegServer
165regsvr32 /s "%_VBOX_DIR%VBoxC.dll"
166@if %fNoProxy% == 1 goto end
167if exist "%_VBOX_DIR%VBoxProxyStub.dll" %windir%\system32\regsvr32 /s "%_VBOX_DIR%VBoxProxyStub.dll"
168@echo off
169goto end
170
171REM Unregister all first, then register them. The order matters here.
172:register_amd64
173if "%WinVerMajor%" == "5" goto register_amd64_legacy
174if not "%WinVerMajor%" == "6" goto register_amd64_not_legacy
175if not "%WinVerMinor%" == "0" goto register_amd64_not_legacy
176:register_amd64_legacy
177set s64BitProxyStub=VBoxProxyStubLegacy.dll
178goto register_amd64_begin
179:register_amd64_not_legacy
180set s64BitProxyStub=VBoxProxyStub.dll
181:register_amd64_begin
182echo s64BitProxyStub=%s64BitProxyStub%
183@echo on
184"%_VBOX_DIR%VBoxSVC.exe" /UnregServer
185%windir%\system32\regsvr32 /s /u "%_VBOX_DIR%VBoxC.dll"
186%windir%\syswow64\regsvr32 /s /u "%_VBOX_DIR%x86\VBoxClient-x86.dll"
187%windir%\system32\regsvr32 /s /u "%_VBOX_DIR%%s64BitProxyStub%"
188%windir%\syswow64\regsvr32 /s /u "%_VBOX_DIR%x86\VBoxProxyStub-x86.dll"
189if %fUninstallOnly% == 1 goto end
190"%_VBOX_DIR%VBoxSVC.exe" /RegServer
191%windir%\system32\regsvr32 /s "%_VBOX_DIR%VBoxC.dll"
192%windir%\syswow64\regsvr32 /s "%_VBOX_DIR%x86\VBoxClient-x86.dll"
193if %fNoProxy% == 1 goto end
194if exist "%_VBOX_DIR%%s64BitProxyStub%" %windir%\system32\regsvr32 /s "%_VBOX_DIR%%s64BitProxyStub%"
195if exist "%_VBOX_DIR%x86\VBoxProxyStub-x86.dll" %windir%\syswow64\regsvr32 /s "%_VBOX_DIR%x86\VBoxProxyStub-x86.dll"
196@echo off
197
198:end
199@endlocal
Note: See TracBrowser for help on using the repository browser.

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