VirtualBox

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

Last change on this file since 55208 was 55208, checked in by vboxsync, 10 years ago

Main/comregister.cmd: for some mysterious reasons the line split doesn't work, so make it one line again as the check is a very valuable time saver

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