OSDN Git Service

Fix EOL character not displayed on ARM64 version
[winmerge-jp/winmerge-jp.git] / ShellExtension / Register.bat
1 @echo off
2 : Register.bat
3 :
4 : ShellExtension.dll is a so called 'Shell Extension'
5 : allowing user to start WinMerge from explorer's context
6 : menu to compare selected files/directories.
7 : However this dll file must be registered for
8 : Windows before it works.
9 :
10 : ShellExtension.dll can be unregistered with command:
11 : "Register.bat /U"
12
13 IF "%OS%" == ""                          Set DLLPATH=%0\..\ShellExtension.dll
14 IF "%PROCESSOR_ARCHITECTURE%" == "x86"   Set DLLPATH=%~dp0%ShellExtensionU.dll
15 IF "%PROCESSOR_ARCHITECTURE%" == "AMD64" Set DLLPATH=%~dp0%ShellExtensionX64.dll
16 IF "%PROCESSOR_ARCHITECTURE%" == "IA64"  Set DLLPATH=%~dp0%ShellExtensionIA64.dll
17 IF "%PROCESSOR_ARCHITECTURE%" == "ARM64" Set DLLPATH=%~dp0%ShellExtensionARM64.dll
18 IF "%PROCESSOR_ARCHITECTURE%" == "ARM" Set DLLPATH=%~dp0%ShellExtensionARM.dll
19
20 SET OPTIONS=
21 FOR %%i IN (%*) DO (
22   IF "%%i" == "/s" SET OPTIONS=%OPTIONS% /s 
23   IF "%%i" == "/S" SET OPTIONS=%OPTIONS% /s 
24 )
25
26 FOR %%i IN (%*) DO (
27   IF "%%i" == "/u" Goto Uninstall
28   IF "%%i" == "/U" Goto Uninstall
29 )
30
31 Echo Registering ShellExtension.dll...
32 IF "%OS%" == "" %WINDIR%\System\RegSvr32 %OPTIONS% "%DLLPATH%"
33 IF "%OS%" == "" Goto End
34 Call :Execute regsvr32 %OPTIONS% "%DLLPATH%"
35 IF EXIST "%~dp0\WinMerge32BitPluginProxy.exe" Call :Execute "%~dp0\WinMerge32BitPluginProxy.exe" /RegServer
36 Goto End
37
38 :Uninstall
39 Echo UnRegistering ShellExtension.dll...
40 IF "%OS%" == "" %WINDIR%\System\RegSvr32 /u %OPTIONS% "%DLLPATH%"
41 IF "%OS%" == "" Goto End
42 Call :Execute regsvr32 /u %OPTIONS% "%DLLPATH%"
43 IF EXIST "%~dp0\WinMerge32BitPluginProxy.exe" Call :Execute "%~dp0\WinMerge32BitPluginProxy.exe" /UnregServer
44 Goto End
45
46 :Execute
47 Ver | %WINDIR%\System32\Find " 5." > NUL
48 IF NOT ERRORLEVEL 1 (
49   rem Windows 2000, XP, Sever 2003
50   %1 %2 %3 %4
51 ) Else (
52   rem Windows Vista, Server 200x, Server 201x, Windows 8, Windows 10
53   Echo args="": For Each a in WScript.Arguments: If InStr^(a, " "^) ^> 0 Then args = args ^& """" ^& a ^& """ " Else args = args ^& a ^& " " End If: Next: CreateObject^("Shell.Application"^).ShellExecute "%~1", args, "", "runas" > "%TEMP%\Elevated.vbs"
54   Wscript //nologo "%TEMP%\Elevated.vbs" %2 %3 %4
55   Del "%TEMP%\Elevated.vbs" 2> NUL
56 )
57 Goto :EOF
58
59 :End
60 CLS