Skip to content

Commit 2975a08

Browse files
authored
Merge pull request #1351 from trycompai/mariano/agent-improvements
[dev] [Marfuen] mariano/agent-improvements
2 parents 8c05fd8 + a313739 commit 2975a08

File tree

1 file changed

+16
-14
lines changed
  • apps/portal/src/app/api/download-agent/scripts

1 file changed

+16
-14
lines changed

apps/portal/src/app/api/download-agent/scripts/windows.ts

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ if not %errorlevel%==0 (
3434
echo A prompt will appear asking for permission. Please click "Yes".
3535
echo If no prompt appears, right-click this file and select "Run as administrator".
3636
echo.
37-
powershell -NoProfile -ExecutionPolicy Bypass -Command "Start-Process -FilePath '%~f0' -Verb RunAs"
37+
powershell -NoProfile -ExecutionPolicy Bypass -Command "Start-Process -Verb RunAs -FilePath '%comspec%' -ArgumentList '/k','\"%~f0\"' -WorkingDirectory '%cd%'"
3838
echo This window will now close. The setup will continue in the new window.
3939
pause
4040
exit /b
@@ -64,45 +64,47 @@ if not defined CHOSEN_DIR (
6464
set "HAS_ERROR=1"
6565
set "ERRORS=!ERRORS!- No writable directory found (Primary: %PRIMARY_DIR%, Fallback: %FALLBACK_DIR%).!nl!"
6666
) else (
67-
set "LOG_FILE=%CHOSEN_DIR%\setup.log"
68-
echo Using directory: %CHOSEN_DIR%
67+
set "MARKER_DIR=%CHOSEN_DIR%"
68+
if not "%MARKER_DIR:~-1%"=="\\" set "MARKER_DIR=%MARKER_DIR%\\"
69+
set "LOG_FILE=%MARKER_DIR%setup.log"
70+
echo Using directory: %MARKER_DIR%
6971
)
7072
echo Logs will be written to: %LOG_FILE%
7173
echo.
7274
7375
REM Write marker files
7476
if defined CHOSEN_DIR (
7577
echo Writing organization marker file...
76-
> "%CHOSEN_DIR%\%ORG_ID%" (echo %ORG_ID%) 2>>"%LOG_FILE%"
78+
> "%MARKER_DIR%%ORG_ID%" (echo %ORG_ID%) 2>>"%LOG_FILE%"
7779
if errorlevel 1 (
7880
color 0E
79-
echo WARNING: Failed writing organization marker file to %CHOSEN_DIR%.
81+
echo WARNING: Failed writing organization marker file to %MARKER_DIR%.
8082
echo [%date% %time%] Failed writing org marker file >> "%LOG_FILE%"
8183
set "HAS_ERROR=1"
8284
set "ERRORS=!ERRORS!- Failed writing organization marker file.!nl!"
8385
) else (
84-
echo [OK] Organization marker file: %CHOSEN_DIR%\%ORG_ID%
86+
echo [OK] Organization marker file: %MARKER_DIR%%ORG_ID%
8587
)
8688
8789
echo Writing employee marker file...
88-
> "%CHOSEN_DIR%\%EMPLOYEE_ID%" (echo %EMPLOYEE_ID%) 2>>"%LOG_FILE%"
90+
> "%MARKER_DIR%%EMPLOYEE_ID%" (echo %EMPLOYEE_ID%) 2>>"%LOG_FILE%"
8991
if errorlevel 1 (
9092
color 0E
91-
echo WARNING: Failed writing employee marker file to %CHOSEN_DIR%.
93+
echo WARNING: Failed writing employee marker file to %MARKER_DIR%.
9294
echo [%date% %time%] Failed writing employee marker file >> "%LOG_FILE%"
9395
set "HAS_ERROR=1"
9496
set "ERRORS=!ERRORS!- Failed writing employee marker file.!nl!"
9597
) else (
96-
echo [OK] Employee marker file: %CHOSEN_DIR%\%EMPLOYEE_ID%
98+
echo [OK] Employee marker file: %MARKER_DIR%%EMPLOYEE_ID%
9799
)
98100
)
99101
100102
REM Set permissive read ACLs for SYSTEM and Administrators
101103
if defined CHOSEN_DIR (
102104
echo Setting permissions on marker files...
103-
icacls "%CHOSEN_DIR%" /inheritance:e >nul 2>&1
104-
icacls "%CHOSEN_DIR%\%ORG_ID%" /grant *S-1-5-18:R *S-1-5-32-544:R /T >nul 2>&1
105-
icacls "%CHOSEN_DIR%\%EMPLOYEE_ID%" /grant *S-1-5-18:R *S-1-5-32-544:R /T >nul 2>&1
105+
icacls "%MARKER_DIR%" /inheritance:e >nul 2>&1
106+
icacls "%MARKER_DIR%%ORG_ID%" /grant *S-1-5-18:R *S-1-5-32-544:R /T >nul 2>&1
107+
icacls "%MARKER_DIR%%EMPLOYEE_ID%" /grant *S-1-5-18:R *S-1-5-32-544:R /T >nul 2>&1
106108
)
107109
108110
echo.
@@ -151,9 +153,9 @@ if %errorlevel%==0 (
151153
echo.
152154
echo Verifying markers...
153155
if defined CHOSEN_DIR (
154-
if not exist "%CHOSEN_DIR%\%EMPLOYEE_ID%" (
156+
if not exist "%MARKER_DIR%%EMPLOYEE_ID%" (
155157
color 0E
156-
echo WARNING: Employee marker file missing at %CHOSEN_DIR%\%EMPLOYEE_ID%
158+
echo WARNING: Employee marker file missing at %MARKER_DIR%%EMPLOYEE_ID%
157159
echo [%date% %time%] Verification failed: employee marker file missing >> "%LOG_FILE%"
158160
set "HAS_ERROR=1"
159161
set "ERRORS=!ERRORS!- Employee marker file missing at %CHOSEN_DIR%\%EMPLOYEE_ID%.!nl!"

0 commit comments

Comments
 (0)