@@ -7,7 +7,12 @@ set "ORIGINAL_DIR=%CD%"
77:: Change to the directory where the script resides
88cd /d %~dp0
99
10- set " targetPath = %USERPROFILE% \AppData\Roaming\Python\Python312\Scripts"
10+ if exist " C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.12_3.12.2544.0_x64__qbz5n2kfra8p0" (
11+ set " targetPath = C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.12_3.12.2544.0_x64__qbz5n2kfra8p0"
12+ ) else if exist " %USERPROFILE% \AppData\Roaming\Python\Python312\Scripts" (
13+ set " targetPath = %USERPROFILE% \\AppData\Roaming\Python\Python312\Scripts"
14+ )
15+
1116set " found = 0"
1217
1318:: Normalize the target path by removing any trailing backslash
@@ -43,6 +48,8 @@ if "!found!"=="0" (
4348
4449:checkDone
4550
51+
52+ call :ConfigureArgComplete
4653call :ConfigureGit
4754call :ConfigureVSCode
4855call :ConfigurePreCommit
@@ -170,3 +177,33 @@ IF %ERRORLEVEL% NEQ 0 (
170177
171178)
172179goto :eof
180+
181+ :ConfigureArgComplete
182+
183+ :: Define paths
184+ set " PROFILE_PATH = %USERPROFILE% \Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1"
185+ set " MODULE_PATH = C:\Program^ Files^ ^ (x86^ )\ardupilot_methodic_configurator\ardupilot_methodic_configurator_command_line_completion.psm1"
186+
187+ :: Create profile directory if it doesn't exist
188+ if not exist " %USERPROFILE% \Documents\WindowsPowerShell" (
189+ mkdir " %USERPROFILE% \Documents\WindowsPowerShell"
190+ )
191+
192+ :: Check if module exists
193+ if not exist " %MODULE_PATH% " (
194+ echo Error: Module file not found at %MODULE_PATH%
195+ pause
196+ exit /b 1
197+ )
198+
199+ :: Add import line to profile if it doesn't exist
200+ powershell -Command " if (-not (Test-Path '%PROFILE_PATH% ')) { New-Item -Path '%PROFILE_PATH% ' -Force } else { $content = Get-Content '%PROFILE_PATH% '; if ($content -notcontains 'Import-Module \" %MODULE_PATH% \" ') { Add-Content '%PROFILE_PATH% ' 'Import-Module \" %MODULE_PATH% \" ' }}"
201+
202+ if %errorLevel% equ 0 (
203+ echo PowerShell profile updated successfully.
204+ echo Please restart PowerShell for changes to take effect.
205+ ) else (
206+ echo Failed to update PowerShell profile.
207+ )
208+
209+ goto :eof
0 commit comments