VirtualBox

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

Last change on this file since 103795 was 98103, checked in by vboxsync, 21 months ago

Copyright year updates by scm.

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