11@ ECHO OFF
2+ SET PROGRAM = python
23IF " %1 " == " --help" GOTO displayhelp
34IF " %1 " == " -h" GOTO displayhelp
45SETLOCAL EnableDelayedExpansion
@@ -7,112 +8,27 @@ IF EXIST DEV (SET NO_DEV=0) ELSE (SET NO_DEV=1)
78REM echo(NO_DEV = %NO_DEV%
89REM GOTO endnopause
910
10- :: net file to test privileges, 1>NUL redirects output, 2>NUL redirects errors
11- :: https://gist.github.com/neremin/3a4020c172053d837ab37945d81986f6
12- :: https://stackoverflow.com/questions/13212033/get-windows-version-in-a-batch-file
13- net session > nul 2 >& 1
14- IF " %errorlevel% " == " 0" ( GOTO START ) ELSE (
15- FOR /f " tokens=4-5 delims=. " %%i in ('ver') do SET VERSION = %%i .%%j
16- IF " %version% " == " 6.1" ( GOTO win7exit )
17- IF " %version% " == " 6.0" ( GOTO win7exit )
18- GOTO getPrivileges
11+ CLS
12+ ECHO Installing / Updating setuptools
13+ %PROGRAM% -m pip install --upgrade setuptools 1 > NUL 2 > NUL
14+ IF %ERRORLEVEL% == 1 (
15+ SET ERRPKG = windows-curses
16+ GOTO piperror
1917)
20-
21- :win7exit
22- ECHO .
23- ECHO Error: You must have Administrative permissions to run this script.
24- ECHO Please start cmd " As Administrator" .
25- ECHO .
26- ECHO If that does not work, ask the system administrator to
27- ECHO install PyRadio for you.
28- ECHO .
29- GOTO endnopause
30-
31- :getPrivileges
32- IF " %version% " == " 6.1" ( GOTO win7exit )
33- IF " %version% " == " 6.0" ( GOTO win7exit )
34-
35- IF " %1 " == " " (
36- CLS
37- ECHO Installing / Updating python modules
38- pip install --upgrade windows-curses 1 > NUL 2 > NUL
39- IF %ERRORLEVEL% == 1 (
40- SET ERRPKG = windows-curses
41- GOTO piperror
42- )
43- pip install --upgrade pywin32 1 > NUL 2 > NUL
44- IF %ERRORLEVEL% == 1 (
45- SET ERRPKG = pywin32
46- GOTO piperror
47- )
48- pip install --upgrade requests 1 > NUL 2 > NUL
49- IF %ERRORLEVEL% == 1 (
50- SET ERRPKG = requests
51- GOTO piperror
52- )
53- pip install --upgrade dnspython 1 > NUL 2 > NUL
54- IF %ERRORLEVEL% == 1 (
55- SET ERRPKG = dnspython
56- GOTO piperror
57- )
58- pip install --upgrade psutil 1 > NUL 2 > NUL
59- IF %ERRORLEVEL% == 1 (
60- SET ERRPKG = psutil
61- GOTO piperror
62- )
63- pip install --upgrade patool 1 > NUL 2 > NUL
64- IF %ERRORLEVEL% == 1 (
65- SET ERRPKG = patool
66- GOTO piperror
67- )
68- pip install --upgrade psutil 1 > NUL 2 > NUL
69- IF %ERRORLEVEL% == 1 (
70- SET ERRPKG = pyunpack
71- GOTO piperror
72- )
73- pip install --upgrade wheel 1 > NUL 2 > NUL
74- IF %ERRORLEVEL% == 1 (
75- SET ERRPKG = wheel
76- GOTO piperror
77- )
18+ ECHO Installing / Updating windows-curses
19+ %PROGRAM% -m pip install --upgrade windows-curses 1 > NUL 2 > NUL
20+ IF %ERRORLEVEL% == 1 (
21+ SET ERRPKG = windows-curses
22+ GOTO piperror
7823)
79- GOTO START
80- IF '%1 '== 'ELEV' ( GOTO START ) ELSE ( ECHO Running elevated in a different window)
81- ECHO >> DOPAUSE
82-
83- SET " batchPath = %~f0 "
84- SET " batchArgs = ELEV"
85-
86- :: Add quotes to the batch path, IF needed
87- SET " script = %0 "
88- SET script = %script:" =%
89- IF '%0 '== '!script! ' ( GOTO PathQuotesDone )
90- SET " batchPath = " " %batchPath% " " "
91- :PathQuotesDone
9224
93- :: Add quotes to the arguments, IF needed.
94- :ArgLoop
95- IF '%1 '== '' ( GOTO EndArgLoop ) ELSE ( GOTO AddArg )
96- :AddArg
97- SET " arg = %1 "
98- SET arg = %arg:" =%
99- IF '%1 '== '!arg! ' ( GOTO NoQuotes )
100- SET " batchArgs = %batchArgs% " %1 " "
101- GOTO QuotesDone
102- :NoQuotes
103- SET " batchArgs = %batchArgs% %1 "
104- :QuotesDone
105- SHIFT
106- GOTO ArgLoop
107- :EndArgLoop
25+ echo pywin32 > requirements.txt
26+ echo requests >> requirements.txt
27+ echo dnspython >> requirements.txt
28+ echo psutil >> requirements.txt
29+ echo wheel >> requirements.txt
30+ echo pylnk >> requirements.txt
10831
109- :: Create and run the vb script to elevate the batch file
110- ECHO SET UAC = CreateObject^ (" Shell.Application" ^ ) > " %temp% \OEgetPrivileges.vbs"
111- ECHO UAC.ShellExecute " cmd" , " /c " " !batchPath! !batchArgs! " " " , " " , " runas" , 1 >> " %temp% \OEgetPrivileges.vbs"
112- " %temp% \OEgetPrivileges.vbs"
113- EXIT /B
114-
115- :START
11632:: Remove the elevation tag and SET the correct working directory
11733IF '%1 '== 'ELEV' ( SHIFT /1 )
11834CD /d %~dp0
@@ -121,7 +37,6 @@ CD /d %~dp0
12137
12238CD ..
12339SET arg1 = %1
124- SET PROGRAM = python
12540
12641
12742:: Get Desktop LINK FILE
@@ -153,7 +68,7 @@ IF "%NO_DEV%" == "1" (
15368)
15469
15570:install
156- %PROGRAM% -m pip install .
71+ %PROGRAM% -m pip install -r requirements.txt .
15772IF %ERRORLEVEL% == 0 GOTO installhtml
15873:installationerror
15974ECHO .
@@ -189,7 +104,7 @@ ECHO *** HTML files copyed to "%APPDATA%\pyradio\help"
189104
190105:: Update lnk file
191106CD pyradio
192- python -c " from win import create_pyradio_link; create_pyradio_link()"
107+ %PROGRAM% -c " from win import create_pyradio_link; create_pyradio_link()"
193108CD ..
194109
195110:: Install lnk file
@@ -198,7 +113,7 @@ COPY /Y %APPDATA%\pyradio\help\*.lnk %DESKTOP% >NUL
198113
199114:: Clean up
200115CD pyradio
201- python -c " from win import clean_up; clean_up()"
116+ %PROGRAM% -c " from win import clean_up; clean_up()"
202117CD ..
203118GOTO toend
204119
@@ -297,7 +212,7 @@ IF "%ANS%" == "y" (
297212)
298213
299214ECHO IF EXIST dirs DEL dirs >> pyremove.bat
300- ECHO python -m pip uninstall -y pyradio>> pyremove.bat
215+ ECHO %PROGRAM% -m pip uninstall -y pyradio>> pyremove.bat
301216ECHO ECHO.>> pyremove.bat
302217ECHO ECHO.>> pyremove.bat
303218:: ECHO ECHO PyRadio successfully uninstalled! >>pyremove.bat
0 commit comments