-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathauthenticator.bat
More file actions
57 lines (48 loc) · 1.79 KB
/
Copy pathauthenticator.bat
File metadata and controls
57 lines (48 loc) · 1.79 KB
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
@SETLOCAL ENABLEEXTENSIONS
@SETLOCAL ENABLEDELAYEDEXPANSION
@REM // ENABLEDELAYEDEXPANSION would allow !var! to expand the variable var at execution time.
@REM // The variables is usually expanded at input time, but when inside of a FOR loop, its assigned with value during initialization.
@REM // This expansion of variable at the input time, causes counter variables not to increment or decrement in FOR loop.
@REM // Parent Directory of Authenticator App
@SET parent=%~dp0
@REM // Get the path of python executable
@REM // If more than one path of python.exe exists, select the 1st one
@SET /A once=0
@FOR /F "usebackq delims=" %%i IN (`where python.exe`) DO (
@IF /I !once! EQU 0 (
@SET pypaths=%%i
@SET /A once=1
)
)
@REM @echo %pypaths%
@cd %parent%
@REM // For Supporting “double-click” execution from Windows Explorer
@SET /A noninteractive=0
@REM ECHO %CMDCMDLINE% | FINDSTR /L /I %COMSPEC% >NUL 2>&1
@ECHO %CMDCMDLINE% | FINDSTR /L /I %parent% >NUL 2>&1
@REM ECHO ERRORLEVEL=%ERRORLEVEL%
@IF %ERRORLEVEL% == 0 SET /A noninteractive=1
@REM // Run the app
"%pypaths%" authenticator.py
@IF ERRORLEVEL 1 (
@REM // If Some Error occured running the app
@REM // Re Run the app to capture the error
"%pypaths%" authenticator.py 2>NUL | findstr /L /I "pip3 install pycryptodome"
@IF ERRORLEVEL 0 (
@REM // If Crypto module is not installed
@ECHO Installing Crypto Library
pip3 install pycryptodome
@IF ERRORLEVEL 0 (
@REM // After successful installation of Crypto Library
@REM // Run the app again
"%pypaths%" authenticator.py
)
)
)
@IF /I !noninteractive! EQU 1 (
REM // Paused the CMD.exe to show the output before exiting
@REM // For bat script, double clicked from Win Explorer
@PAUSE
)
@ENDLOCAL
@EXIT /B 0