With Windows Powershell, we are able to start a process as another user, with the command Start-Process Credential parameter. But in some conditions, you will get this error: The system cannot find the file specified. or The Directory name is invalid.
The error occurs only if the parameter Credential is set. If not, Internet Explorer is starting. Let’s see how to resolve this issue.
Start-Process Credential errors
Maybe you tried to execute the powershell command:
Start-Process -credential (Get-Credential) -FilePath "iexplore.exe" |
Even with the full path specified, another error occurs: The Directory name is invalid.
Start-Process -credential (Get-Credential) -FilePath "C:\Program Files (x86)\Internet Explorer\iexplore.exe" |
The Start-Process cmdlet has the WorkingDirectory parameter. If we use it with the executable name, the error is one again: The system cannot find the file specified.
Start-Process -credential (Get-Credential) -FilePath "iexplore.exe" -WorkingDirectory "C:\Program Files (x86)\Internet Explorer\" |
After troubleshooting, these errors occur when the $HOMEDRIVE and $HOMEPATH are set on the logged user account. This can be done by GPO or on the account properties.
The workaround is to use the full path of the executable AND use the working directory:
Start-Process -credential (Get-Credential) -FilePath "C:\Program Files (x86)\Internet Explorer\iexplore.exe" -WorkingDirectory "C:\Program Files (x86)\Internet Explorer\" |
User Membership
When you try to run a process on a computer with a external user in a trusted forest, the user must be in the local computer Users group. Otherwise you will get an Access Denied error.
More
You can get more information about the cmdlet Start-Process here.