Powershell

Powershell – Start-Process Credential error

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 specifiedor The Directory name is invalid.

Start-Process Credential The file cannot find the file

Start-Process Credential The file cannot find the file

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"
Start-Process The file cannot find the file

Start-Process The file cannot find the file

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 Directory Name is invalid

The Directory Name is invalid

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\"
Start-Process Working Directory error

Start-Process Working Directory error

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\"
Start-Process Credential no errors

Start-Process Credential no errors

 

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.

Share

Leave a Reply

Your email address will not be published. Required fields are marked *