Skip to content
This repository was archived by the owner on Aug 29, 2025. It is now read-only.

Commit 36416b1

Browse files
profile.ps1: Ensure we elevate processes if the runas verb is passed in.
1 parent 0a98a91 commit 36416b1

1 file changed

Lines changed: 13 additions & 7 deletions

File tree

src/profile.ps1

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,19 @@ function Start-Process {
137137
$processStartInfo = New-Object System.Diagnostics.ProcessStartInfo
138138
$processStartInfo.FileName = $FilePath
139139
$processStartInfo.Arguments = $ArgumentList -join ' '
140-
$processStartInfo.UseShellExecute = $false
140+
141+
# Set UseShellExecute to true if the verb is 'runas'
142+
if ($Verb -eq 'runas') {
143+
$processStartInfo.UseShellExecute = $true
144+
} else {
145+
$processStartInfo.UseShellExecute = $false
146+
}
147+
148+
# Set verb
149+
if ($Verb) {
150+
Write-Message "Setting verb: $Verb"
151+
$processStartInfo.Verb = $Verb
152+
}
141153

142154
# Set window style if needed
143155
switch ($WindowStyle) {
@@ -153,12 +165,6 @@ function Start-Process {
153165
$processStartInfo.WorkingDirectory = $WorkingDirectory
154166
}
155167

156-
# Set verb if provided
157-
if ($Verb) {
158-
Write-Message "Setting verb: $Verb"
159-
$processStartInfo.Verb = $Verb
160-
}
161-
162168
# Handle input/output redirection
163169
if ($RedirectStandardOutput) {
164170
Write-Message "Redirecting standard output"

0 commit comments

Comments
 (0)