-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.cmd
More file actions
134 lines (113 loc) · 3.87 KB
/
Copy pathinstall.cmd
File metadata and controls
134 lines (113 loc) · 3.87 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
@echo off
rem Example install batch file for Windows environment.
rem Run from the application directory
rem Required files:
rem logo.png logo file displayed by application at runtime
rem NPI Extraction.lnk create this shortcut file to reflect your installation and runtime requirements!!
rem npi.py The main application file
rem python-3.12.3-amd64.exe The Python source file
rem requirements.txt Used by Python to install required libraries
rem unattend.xml Required to run a "hands-off" install of Python.
rem
setlocal enabledelayedexpansion
title Install NPI Extraction Tool
echo Sourcing from: %~dp0
:: Prevent early exit on errors
set "ERRORFLAG=0"
set "PROJECT_DIR=%USERPROFILE%\NPIExtract"
set "VENV_DIR=%PROJECT_DIR%\venv"
::==========
:: Determine where the Desktop directory is located!!! It's NOT always %USERPROFILE%\Desktop !!!
:: Define your target registry key and value name
set "REG_KEY=HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders"
set "REG_VALUE=Desktop"
:: Extract the value data
for /f "tokens=2*" %%A in ('reg query "%REG_KEY%" /v "%REG_VALUE%" 2^>nul') do (
set "REG_DATA=%%B"
)
:: Verify and use your variable
if defined REG_DATA (
set "DESKTOP_DIR=%REG_DATA%"
) else (
set "DESKTOP_DIR=%USERPROFILE%\Desktop"
)
:: End of Desktop location determination
::==========
:: Expand the variables
call set "DESKTOP_DIR=%DESKTOP_DIR%"
echo Desktop located at %DESKTOP_DIR%
:: pause
echo Checking for existing Python installation...
python --version >nul 2>&1
if %errorlevel% neq 0 (
echo Python not found.
set INSTALL=TRUE
) else (
for /f "tokens=2 delims= " %%a in ('python --version 2^>^&1') do set "VERSION=%%a"
echo Found Python version: !VERSION!
if "%VERSION%" equ "3.12.3" (
set INSTALL=FALSE
set "PYTHON_PATH=%LocalAppData%\Programs\Python\Python312\python.exe"
set VENV_PYTHON=%VENV_DIR%\scripts\python.exe
) else (
set INSTALL=TRUE
)
)
if "%INSTALL%" equ "TRUE" (
"%~dp0\python-3.12.3-amd64.exe" /passive
set "PYTHON_PATH=%LocalAppData%\Programs\Python\Python312\python.exe"
set VENV_PYTHON=%VENV_DIR%\scripts\python.exe
)
echo Creating project folder...
if not exist "%PROJECT_DIR%" md "%PROJECT_DIR%"
echo Creating virtual environment...
call "%PYTHON_PATH%" -m venv "%VENV_DIR%"
if %errorlevel% neq 0 (
echo ERROR: Failed to create virtual environment.
set "ERRORFLAG=1"
goto :END
)
echo Virtual environment created at: %VENV_DIR%
echo Activating virtual environment and upgrading pip...
call "%VENV_DIR%\Scripts\activate.bat"
call "%PYTHON_PATH%" -m pip install --upgrade pip
if exist "%~dp0\requirements.txt" (
echo Installing required Python packages in venv...
call "%VENV_PYTHON%" -m pip uninstall -y PySimpleGUI
call "%VENV_PYTHON%" -m pip install -r "%~dp0\requirements.txt"
)
) else (
echo No requirements.txt found — skipping dependency install.
)
if %errorlevel% neq 0 (
echo ERROR: Failed to install dependencies.
set "ERRORFLAG=1"
goto :END
)
echo Copying files
echo copy /y "%~dp0\npi.py" %PROJECT_DIR%
copy /y "%~dp0\npi.py" %PROJECT_DIR%
echo copy /y "%~dp0\logo.png" %PROJECT_DIR%
copy /y "%~dp0\logo.png" %PROJECT_DIR%
echo copy /y "%~dp0\data-extraction.ico" %PROJECT_DIR%
copy /y "%~dp0\data-extraction.ico" %PROJECT_DIR%
echo copy /y "%~dp0\NPI Extraction.lnk" %DESKTOP_DIR%
copy /y "%~dp0\NPI Extraction.lnk" %DESKTOP_DIR%
:: pause
echo Launching NPI Extraction Tool...
start "" "%DESKTOP_DIR%\NPI Extraction.lnk"
echo.
:END
if %ERRORFLAG% neq 0 (
echo.
echo ===============================
echo INSTALLATION FAILED
echo ===============================
pause
) else (
echo.
echo ===============================
echo INSTALLATION COMPLETE
echo ===============================
timeout /t 5
)