
Start-Process -Verb RunAs -WindowStyle Hidden cmd. $dir = $PWD.ProviderPath # use the current dir. Since changing to the working directory must happen in the new, elevated process, a helper shell process is needed to perform this operation, which is best done via cmd.exe (for better performance): $exeToLaunch = 'Notepad.exe' # may include arguments Workaround for launching a GUI application elevated from a given working directory: The Start-Process cmdlet allows you to run one or multiple processes on your computer from within PowerShell. Caveat: If the native path is on a mapped network drive, this won't work, because elevated processes do not see the same drive mappings in that event, pass the underlying UNC path.ProviderPath property ensures that a file-system- native path is used (based on drive letters also seen in cmd.exe, for instance), given that the calling session's current location may be based on a PowerShell-only drive (see New-PSDrive) that the elevated process may not have defined (at all or not based on the same root location). Output for the comands 1 and 2: Type yes or no: actually typed no Typed yes. echo no powershell Start-Process -NoNewWindow -FilePath C:CAPCAP-Installertest.bat. echo no powershell Set-Location -Path C:CAPCAP-Installer Start-Process -NoNewWindow. Using a here-string ( isn't strictly necessary, but simplifies the embedded quoting with a regular expandable string ( "."), the embedded " must be escaped as `" (or ""). Below are some of the commands that I have tried.(To use the current directory without an intermediate variable, replace "dir" with "$($PWD.ProviderPath)". In the pure console the command launches iexplorer.exe after credentials have been applied. Start-Process -Verb RunAs powershell.exe -c Set-Location -LiteralPath embedded "." quoting around $dir ensures that paths with spaces are also handled correctly. Start-Process 'C:\Program Files\Internet Explorer\iexplore.exe' -Credential (Get-Credential) I get 2 very different results whether I use Powershell Console or PowershellISE. NET executable, a workaround that changes to the desired working folder in the new process is therefore required to offer a more robust alternative to ふゆな's helpful answer: $dir = $PWD.ProviderPath # use the current dir. NET API that PowerShell uses behind the scenes (see ), as of this writing (.NET 6.0.0-preview.4.21253.7). The problem exists at the level of the.
#POWERSHELL STARTPROCESS ARGUMENTLIST INTERNET EXPLORER WINDOWS#
cmd.exe and, curiously, powershell.exe (the Windows PowerShell CLI) do not, and invariably use C:\Windows\System32.pwsh.exe (the PowerShell (Core) CLI) does honor it.

By default, Start-Process creates a new process that inherits all the environment variables that are defined in the current process. When using Start-Process with -Verb RunAs, a -WorkingDirectory argument is honored if the target executable is a. The Start-Process cmdlet starts one or more processes on the local computer.
