Skip to content

Commit b14a919

Browse files
committed
fix(completion): fix powershell cmd completion
1 parent 62c68ea commit b14a919

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

SetupDeveloperPC.bat

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -182,28 +182,29 @@ goto :eof
182182

183183
:: Define paths
184184
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"
185+
set "MODULE_PATH=C:\Program Files (x86)\ardupilot_methodic_configurator\ardupilot_methodic_configurator_command_line_completion.psm1"
186186

187187
:: Create profile directory if it doesn't exist
188-
if not exist "%USERPROFILE%\Documents\WindowsPowerShell" (
189-
mkdir "%USERPROFILE%\Documents\WindowsPowerShell"
188+
if not exist "!USERPROFILE!\Documents\WindowsPowerShell" (
189+
mkdir "!USERPROFILE!\Documents\WindowsPowerShell"
190190
)
191191

192192
:: Check if module exists
193-
if not exist "%MODULE_PATH%" (
194-
echo Error: Module file not found at %MODULE_PATH%
193+
if not exist "!MODULE_PATH!" (
194+
echo Error: Module file not found at !MODULE_PATH!
195195
pause
196196
exit /b 1
197197
)
198198

199199
:: 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%\"' }}"
200+
powershell -NoProfile -Command "$ProfilePath='!PROFILE_PATH!'.Replace('\','\\'); $ModulePath='!MODULE_PATH!'.Replace('\','\\'); if (-not (Test-Path $ProfilePath)) { New-Item -Path $ProfilePath -Force | Out-Null }; $content = Get-Content $ProfilePath -ErrorAction SilentlyContinue; if (-not ($content -contains \"Import-Module `\"$ModulePath`\"\")) { Add-Content $ProfilePath \"Import-Module `\"$ModulePath`\"\" }"
201201

202-
if %errorLevel% equ 0 (
202+
if !ERRORLEVEL! equ 0 (
203203
echo PowerShell profile updated successfully.
204204
echo Please restart PowerShell for changes to take effect.
205205
) else (
206206
echo Failed to update PowerShell profile.
207+
exit /b 1
207208
)
208209

209210
goto :eof

0 commit comments

Comments
 (0)