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