VirtualBox

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

Last change on this file since 51611 was 51611, checked in by vboxsync, 11 years ago

Old 4NT versions cannot handle ProgramFiles(x86), changed the test.

  • Property svn:eol-style set to CRLF
  • Property svn:keywords set to Author Date Id Revision
File size: 6.8 KB
Line 
1@echo off
2REM $Id: comregister.cmd 51611 2014-06-12 11:40:18Z vboxsync $
3REM
4REM Script to register the VirtualBox COM classes
5REM (both inproc and out-of-process)
6REM
7
8REM
9REM Copyright (C) 2006-2013 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
23REM Figure out where the script lives first, so that we can invoke the
24REM correct VBoxSVC and register the right VBoxC.dll.
25REM
26
27REM Determine the current directory.
28set _SCRIPT_CURDIR=%CD%
29for /f "tokens=*" %%d in ('cd') do set _SCRIPT_CURDIR=%%d
30
31REM Determine a correct self - by %0.
32set _SCRIPT_SELF=%0
33if exist "%_SCRIPT_SELF%" goto found_self
34set _SCRIPT_SELF=%_SCRIPT_SELF%.cmd
35if exist "%_SCRIPT_SELF%" goto found_self
36
37REM Determine a correct self - by current working directory.
38set _SCRIPT_SELF=%_SCRIPT_CURDIR%\comregister.cmd
39if exist "%_SCRIPT_SELF%" goto found_self
40
41REM Determine a correct self - by the PATH
42REM This is very verbose because nested for loops didn't work out.
43for /f "tokens=1 delims=;" %%d in ("%PATH%") do set _SCRIPT_SELF=%%d\comregister.cmd
44if exist "%_SCRIPT_SELF%" goto found_self
45for /f "tokens=2 delims=;" %%d in ("%PATH%") do set _SCRIPT_SELF=%%d\comregister.cmd
46if exist "%_SCRIPT_SELF%" goto found_self
47for /f "tokens=3 delims=;" %%d in ("%PATH%") do set _SCRIPT_SELF=%%d\comregister.cmd
48if exist "%_SCRIPT_SELF%" goto found_self
49for /f "tokens=4 delims=;" %%d in ("%PATH%") do set _SCRIPT_SELF=%%d\comregister.cmd
50if exist "%_SCRIPT_SELF%" goto found_self
51for /f "tokens=5 delims=;" %%d in ("%PATH%") do set _SCRIPT_SELF=%%d\comregister.cmd
52if exist "%_SCRIPT_SELF%" goto found_self
53for /f "tokens=6 delims=;" %%d in ("%PATH%") do set _SCRIPT_SELF=%%d\comregister.cmd
54if exist "%_SCRIPT_SELF%" goto found_self
55for /f "tokens=7 delims=;" %%d in ("%PATH%") do set _SCRIPT_SELF=%%d\comregister.cmd
56if exist "%_SCRIPT_SELF%" goto found_self
57for /f "tokens=8 delims=;" %%d in ("%PATH%") do set _SCRIPT_SELF=%%d\comregister.cmd
58if exist "%_SCRIPT_SELF%" goto found_self
59for /f "tokens=9 delims=;" %%d in ("%PATH%") do set _SCRIPT_SELF=%%d\comregister.cmd
60if exist "%_SCRIPT_SELF%" goto found_self
61for /f "tokens=10 delims=;" %%d in ("%PATH%") do set _SCRIPT_SELF=%%d\comregister.cmd
62if exist "%_SCRIPT_SELF%" goto found_self
63for /f "tokens=11 delims=;" %%d in ("%PATH%") do set _SCRIPT_SELF=%%d\comregister.cmd
64if exist "%_SCRIPT_SELF%" goto found_self
65for /f "tokens=12 delims=;" %%d in ("%PATH%") do set _SCRIPT_SELF=%%d\comregister.cmd
66if exist "%_SCRIPT_SELF%" goto found_self
67for /f "tokens=13 delims=;" %%d in ("%PATH%") do set _SCRIPT_SELF=%%d\comregister.cmd
68if exist "%_SCRIPT_SELF%" goto found_self
69for /f "tokens=14 delims=;" %%d in ("%PATH%") do set _SCRIPT_SELF=%%d\comregister.cmd
70if exist "%_SCRIPT_SELF%" goto found_self
71for /f "tokens=15 delims=;" %%d in ("%PATH%") do set _SCRIPT_SELF=%%d\comregister.cmd
72if exist "%_SCRIPT_SELF%" goto found_self
73for /f "tokens=16 delims=;" %%d in ("%PATH%") do set _SCRIPT_SELF=%%d\comregister.cmd
74if exist "%_SCRIPT_SELF%" goto found_self
75for /f "tokens=17 delims=;" %%d in ("%PATH%") do set _SCRIPT_SELF=%%d\comregister.cmd
76if exist "%_SCRIPT_SELF%" goto found_self
77for /f "tokens=18 delims=;" %%d in ("%PATH%") do set _SCRIPT_SELF=%%d\comregister.cmd
78if exist "%_SCRIPT_SELF%" goto found_self
79for /f "tokens=19 delims=;" %%d in ("%PATH%") do set _SCRIPT_SELF=%%d\comregister.cmd
80if exist "%_SCRIPT_SELF%" goto found_self
81for /f "tokens=20 delims=;" %%d in ("%PATH%") do set _SCRIPT_SELF=%%d\comregister.cmd
82if exist "%_SCRIPT_SELF%" goto found_self
83echo Warning: Not able to determin the comregister.cmd location.
84set _VBOX_DIR=
85goto register
86
87:found_self
88set _VBOX_DIR=
89cd "%_SCRIPT_SELF%\.."
90for /f "tokens=*" %%d in ('cd') do set _VBOX_DIR=%%d\
91cd "%_SCRIPT_CURDIR%"
92
93REM
94REM Check for 64-bitness.
95REM
96set fIs64BitWindows=0
97if not "%ProgramW6432%x" == "x" set fIs64BitWindows=1
98if exist "%windir\syswow64\kernel32.dll" set fIs64BitWindows=1
99
100REM
101REM Figure out the Windows version as the proxy stub requires 6.0 or later (at least for 64-bit).
102REM
103set WinVer=Version 4.0.1381
104set WinVerMajor=4
105set WinVerMinor=0
106set WinVerBuild=1381
107for /f "tokens=2 delims=[]" %%a in ('ver') do set WinVer=%%a
108for /f "tokens=2,3,4 delims=. " %%a in ("%WinVer%") do (
109 set WinVerMajor=%%a
110 set WinVerMinor=%%b
111 set WinVerBuild=%%c
112)
113REM echo WinVerMajor=%WinVerMajor% WinVerMinor=%WinVerMinor% WinVerBuild=%WinVerBuild% WinVer=%WinVer%
114
115REM
116REM Parse arguments.
117REM
118set fNoProxy=0
119if "%WinVerMajor%" LSS "6" set fNoProxy=1
120set fUninstallOnly=0
121
122:arg_loop
123if "%1x" == "x" goto arg_done
124
125if "%1" == "-u" goto arg_uninstall
126if "%1" == "--uninstall" goto arg_uninstall
127if "%1" == "--proxy" goto arg_proxy
128if "%1" == "--no-proxy" goto arg_no_proxy
129echo syntax error: Unknown option %1
130echo usage: comregister.cmd [-u,--uninstall] [--no-proxy] [--proxy]
131goto end
132
133:arg_uninstall
134set fUninstallOnly=1
135goto arg_next
136
137:arg_proxy
138set fNoProxy=0
139goto arg_next
140
141:arg_no_proxy
142set fNoProxy=1
143goto arg_next
144
145:arg_next
146shift
147goto arg_loop
148:arg_done
149
150REM
151REM Do the registrations.
152REM
153@if %fIs64BitWindows% == 1 goto register_amd64
154
155:register_x86
156@echo on
157%_VBOX_DIR%VBoxSVC.exe /UnregServer
158regsvr32 /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
162regsvr32 /s %_VBOX_DIR%VBoxC.dll
163@if %fNoProxy% == 1 goto end
164if exist %_VBOX_DIR%VBoxProxyStub.dll %windir%\system32\regsvr32 /s %_VBOX_DIR%VBoxProxyStub.dll
165@echo off
166goto end
167
168REM 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
181if exist %_VBOX_DIR%VBoxProxyStub.dll %windir%\system32\regsvr32 /s %_VBOX_DIR%VBoxProxyStub.dll
182if exist %_VBOX_DIR%VBoxProxyStub-x86.dll %windir%\system32\regsvr32 /s %_VBOX_DIR%VBoxProxyStub-x86.dll
183@echo off
184
185:end
186@endlocal
187
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