Skip to content

Commit e8a29da

Browse files
committed
Changed some env logic
1 parent b086b22 commit e8a29da

File tree

4 files changed

+38
-5
lines changed

4 files changed

+38
-5
lines changed

src/ControlHub.exe

-345 Bytes
Binary file not shown.

src/install.bat

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,20 @@ type nul > "%PROGRAMDATA%\ControlHub\logs\error.log"
1010

1111
icacls "%PROGRAMDATA%\ControlHub" /grant *S-1-5-32-545:(OI)(CI)M /T
1212

13+
set "TARGET=%~dp0python"
14+
15+
:: Remove existing permissions
16+
icacls "%TARGET%" /reset /T /C /Q
17+
18+
:: Remove all inherited permissions
19+
icacls "%TARGET%" /inheritance:r /remove:g /T /C /Q
20+
21+
:: Recursively grant full control to Everyone, Users, and specific SIDs
22+
icacls "%TARGET%" /grant Everyone:(OI)(CI)F /T /C /Q
23+
icacls "%TARGET%" /grant Users:(OI)(CI)F /T /C /Q
24+
icacls "%TARGET%" /grant *S-1-5-32-545:(OI)(CI)F /T /C /Q
25+
icacls "%TARGET%" /grant *S-1-5-32-544:(OI)(CI)F /T /C /Q
26+
1327
:: Download and install pip requirements
1428
:: python\ipython.bat -m pip install --upgrade -r requirements.txt
1529

src/ipython.bat

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,16 @@
11
@echo off
2+
setlocal
3+
4+
if defined CONTROLHUB (
5+
set "BASE_DIR=%CONTROLHUB%\python\"
6+
) else (
7+
set "BASE_DIR=%~dp0"
8+
)
9+
210
set PYTHONNOUSERSITE=1
311
set PYTHONUSERBASE=
412
set PIP_USER=false
513
set PIP_PREFIX=
6-
set PIP_TARGET=%~dp0Lib\site-packages
14+
set PIP_TARGET=%BASE_DIR%Lib\site-packages
715

8-
"%~dp0python.exe" %*
16+
"%BASE_DIR%python.exe" %*

src/main.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,18 @@
3333
app_path = os.getcwd()
3434
python_executable = os.path.join(app_path, "python", "ipython.bat")
3535

36+
python_lib_path = os.path.join(app_path, "python", "Lib", "site-packages")
37+
python_env = {
38+
"PYTHONNOUSERSITE": "1",
39+
"PYTHONUSERBASE": "",
40+
"PYTHONPATH": python_lib_path,
41+
"PIP_USER": "false",
42+
"PIP_PREFIX": "",
43+
"PIP_TARGET": python_lib_path,
44+
"PYTHONIOENCODING": "utf-8",
45+
"PYTHONUTF8": "1",
46+
}
47+
3648
program_data = os.getenv("PROGRAMDATA")
3749
logs_base = os.path.join(program_data, "ControlHub")
3850
logs_path = os.path.join(logs_base, "logs")
@@ -158,15 +170,14 @@ async def run_command(
158170
creationflags = subprocess.CREATE_NO_WINDOW
159171

160172
process = await asyncio.create_subprocess_exec(
161-
*command,
173+
*("cmd", "/C", *command),
162174
stdout=asyncio.subprocess.PIPE,
163175
stderr=asyncio.subprocess.PIPE,
164176
creationflags=creationflags,
165177
cwd=cwd,
166178
env={
167179
**os.environ,
168-
"PYTHONIOENCODING": "utf-8",
169-
"PYTHONUTF8": "1",
180+
**python_env,
170181
**additional_env,
171182
},
172183
)

0 commit comments

Comments
 (0)