0

The question is probably best explained with the scenario, where I realized the two programs are operating differently.

I had an old backup from my Linux days on my hard drive containing a file named con. As MSDN states, con is a reserved device name and may not be used for files:

Do not use the following reserved device names for the name of a file:

CON, PRN, AUX, NUL, COM1, COM2, COM3, COM4, COM5, COM6, COM7, COM8, COM9, LPT1, LPT2, LPT3, LPT4, LPT5, LPT6, LPT7, LPT8, and LPT9

So I had problems deleting the file, but with proper name escaping as I found it in this command from a Super User answer, I was able to delete it:

del "\\.\F:\Movies\Con Man\Con.Man.2018.720p.WEBRip.x264-[YTS.AM].mp4"

First, I tried to delete the file with the given command via PowerShell. It threw an error saying the directory or drive does not exist. Only C:\WINDOWS\System32\cmd.exe was able to delete the file. I ran both shells with administrator permissions.

So from this point I simply wanted to know: Why do they behave differently? Is there some sort of sepearate permission level for PowerShell or is it running in some sort of special sandbox?

1 Answers1

0

Neither.

Command Prompt is a continuation from old MS-DOS where the only way to communicate with special devices was to use their device names: PRN, CON, Etc...

This basically means that a file that is called by a device, followed by a period is illegal in windows. MS-DOS has a workaround for it, but Powershell doesn't. This basically means you cannot work with a file that violated this illegal filename in windows.

So yes, they are very different for that reason. Not just in what they can do, but the entire syntax is different. Powershell can be used to do things that Command Prompt can, but not the other way around.

LPChip
  • 66,193