mstsc : The term 'mstsc' is not recognized as the name of a cmdlet, function, script file.

Highlighted
Occasional Visitor

I am using mstsc /v:publicIpAddress command to create remote desktop connection from local computer. but getting this error 

mstsc: The term 'mstsc' is not recognized as the name of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

how to create remote desktop connection using CLI/powershell?

3 Replies
Highlighted

@priyanka2289 I am also getting the same error running this command on Powershell in my local machine.

Highlighted

@priyanka2289 Please let me know if you have got any solution to this.

Highlighted

Hi @priyanka2289 ,

I can imagine two possibilities, the first one is that you have an environment variable issue and the second is that you  just don't have the mstsc.exe, (maybe erased).
I would start looking for the executable, that file should be inside the system32 folder, so you could just do a dir to look for it, or something like this:

 

Get-ChildItem ((Get-Item env:\windir).value + '\system32\mstsc.exe') | select FullName, Length 

 

The output should be the file fullname and the file size, if you get that output try run the mstsc.exe withe the full path, if you get an error like:  "Get-ChildItem : Cannot find path 'C:\windows\system32\mstsc.exe' because it does not exist."  you could try copying the executable from another similar O.S.
Also you can allways run  SFC /Scannow, to fix any corrupted system file,
https://support.microsoft.com/en-us/help/929833/use-the-system-file-checker-tool-to-repair-missing-o...

 

If you don't get the path from the earlier command, you could take a look on the environment variables , please post any update.