CMD.exe, File Association , PowerShell

Today as a test I tried changing the file association of '.bat' files to PowerShell and it failed horribly. Then I tried to change the association back to 'CMD' and it will not run thus the machine is broken. I have two questions:

1.      I thought PowerShell can run batch files?
2.      Why didn’t changing to association to ‘CMD.EXE’ work?
Who is Participating?
QlemoConnect With a Mentor Batchelor and DeveloperCommented:
Associating .bat or .cmd with PowerShell is nonsense. Calling batch files from within PS can make sense, but should be avoided, as the results are strings, and cannot be processed as easily as cmdlet results (= objects) within PS.

You can change associations in cmd.exe with assoc and ftype:
REM view existing association:
assoc .bat
REM put the result into ftype (instead of batfile) to see what is really behind that:
ftype batfile
REM reset to default
assoc .bat=batfile

Open in new window

Will SzymkowskiConnect With a Mentor Senior Solution ArchitectCommented:
You can run .BAT files within Powershell but you have to call the process cmd.exe before the batch file can be run.

Take a look at the following link for details/examples...

KonfigurationKingAuthor Commented:
what about changing the association back to the way it was originally?
Will SzymkowskiSenior Solution ArchitectCommented:
You need to make sure that the file association and file extension is correct. Try creating a new batch file and use the above link for the syntax.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.