forked from rizonesoft/Notepad3
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Version.cmd
38 lines (33 loc) · 1.18 KB
/
Version.cmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
:: - USAGE: do not wrap by 'call' "%~dpn0.cmd" (continue parent shell after exit /b 0)
:: - Admin rights:
:: PowerShell.exe -NoProfile -Command "& {Start-Process PowerShell.exe -ArgumentList '-NoProfile -ExecutionPolicy Bypass -File ""%~dpn0.ps1""' -Verb RunAs}"
@echo off
setlocal enableextensions
set SCRIPTNAME=%~dpn0.ps1
set ARGS=%*
if ["%~1"] neq [""] call :ESCAPE_ARGS
:POWERSHELL
PowerShell.exe -NoProfile -NonInteractive -NoLogo -ExecutionPolicy Unrestricted -Command "& { $ErrorActionPreference = 'Stop'; & '%SCRIPTNAME%' @args; Exit $LastExitCode }" %ARGS%
set EXITCODE=%ERRORLEVEL%
::ECHO ERRORLEVEL=%EXITCODE%
:: Pause for 4 seconds to verify the "Notepad3 version number:" before exiting
:: ============================================================================
ping -n 5 127.0.0.1>nul
goto :END
:ESCAPE_ARGS
set ARGS=%ARGS:"=\"%
set ARGS=%ARGS:`=``%
set ARGS=%ARGS:'=`'%
set ARGS=%ARGS:$=`$%
set ARGS=%ARGS:{=`}%
set ARGS=%ARGS:}=`}%
set ARGS=%ARGS:(=`(%
set ARGS=%ARGS:)=`)%
set ARGS=%ARGS:,=`,%
set ARGS=%ARGS:^%=%
goto:eof
:END
:: - make EXITCODE survive 'endlocal'
endlocal & set EXITCODE=%EXITCODE%
:: -call exit only in case of
if not [%EXITCODE%]==[0] exit /b %EXITCODE%