VirtualBox

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

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

comregister.cmd: Fixed another wow64 thing.

  • Property svn:eol-style set to CRLF
  • Property svn:keywords set to Author Date Id Revision
File size: 7.1 KB
Line 
1@echo off
2REM $Id: comregister.cmd 59365 2016-01-17 05:14:34Z vboxsync $
3REM
4REM Script to register the VirtualBox COM classes
5REM (both inproc and out-of-process)
6REM
7
8REM
9REM Copyright (C) 2006-2015 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
123if "%WinVerMajor%" == "5" set fNoProxy=1
124if "%WinVerMajor%" == "4" set fNoProxy=1
125set fUninstallOnly=0
126
127:arg_loop
128if "%1x" == "x" goto arg_done
129
130if "%1" == "-u" goto arg_uninstall
131if "%1" == "--uninstall" goto arg_uninstall
132if "%1" == "--proxy" goto arg_proxy
133if "%1" == "--no-proxy" goto arg_no_proxy
134echo syntax error: Unknown option %1
135echo usage: comregister.cmd [-u,--uninstall] [--no-proxy] [--proxy]
136goto end
137
138:arg_uninstall
139set fUninstallOnly=1
140goto arg_next
141
142:arg_proxy
143set fNoProxy=0
144goto arg_next
145
146:arg_no_proxy
147set fNoProxy=1
148goto arg_next
149
150:arg_next
151shift
152goto arg_loop
153:arg_done
154
155REM
156REM Do the registrations.
157REM
158@if %fIs64BitWindows% == 1 goto register_amd64
159
160:register_x86
161@echo on
162"%_VBOX_DIR%VBoxSVC.exe" /UnregServer
163regsvr32 /s /u "%_VBOX_DIR%VBoxC.dll"
164%windir%\system32\regsvr32 /s /u "%_VBOX_DIR%VBoxProxyStub.dll"
165@if %fUninstallOnly% == 1 goto end
166"%_VBOX_DIR%VBoxSVC.exe" /RegServer
167regsvr32 /s "%_VBOX_DIR%VBoxC.dll"
168@if %fNoProxy% == 1 goto end
169if exist "%_VBOX_DIR%VBoxProxyStub.dll" %windir%\system32\regsvr32 /s "%_VBOX_DIR%VBoxProxyStub.dll"
170@echo off
171goto end
172
173REM Unregister all first, then register them. The order matters here.
174:register_amd64
175@echo on
176"%_VBOX_DIR%VBoxSVC.exe" /UnregServer
177%windir%\system32\regsvr32 /s /u "%_VBOX_DIR%VBoxC.dll"
178%windir%\syswow64\regsvr32 /s /u "%_VBOX_DIR%x86\VBoxClient-x86.dll"
179%windir%\system32\regsvr32 /s /u "%_VBOX_DIR%VBoxProxyStub.dll"
180%windir%\syswow64\regsvr32 /s /u "%_VBOX_DIR%x86\VBoxProxyStub-x86.dll"
181if %fUninstallOnly% == 1 goto end
182"%_VBOX_DIR%VBoxSVC.exe" /RegServer
183%windir%\system32\regsvr32 /s "%_VBOX_DIR%VBoxC.dll"
184%windir%\syswow64\regsvr32 /s "%_VBOX_DIR%x86\VBoxClient-x86.dll"
185if %fNoProxy% == 1 goto end
186if exist "%_VBOX_DIR%VBoxProxyStub.dll" %windir%\system32\regsvr32 /s "%_VBOX_DIR%VBoxProxyStub.dll"
187if exist "%_VBOX_DIR%x86\VBoxProxyStub-x86.dll" %windir%\syswow64\regsvr32 /s "%_VBOX_DIR%x86\VBoxProxyStub-x86.dll"
188@echo off
189
190:end
191@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