gfody/PowershellModules

RunAs : Exception calling "Start" with "7" argument(s): "The directory name is invalid"

hubert3 opened this issue · 1 comments

Trying to run an EXE in the current working path and get this error regardless of whether I specify file.exe, .\file.exe, c:\fullpath\file.exe or just cmd

Test-Path returns true but always getting this exception from [RunAs]::Start, specifically the CreateProcessWithLogonW call always fails even though currentDirectory and applicationName are valid full absolute paths

Turns out this is a Win32 API limitation, CreateProcessWithLogonW() does not accept network paths as the current working directory or in the executable image path, as documented here https://learn.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-createprocesswithlogonw