Use of the root directory C:\ is suspicious, as in C:\ProductName.txt
. You should not put any files in C:\ that do not need to be there. Put the file in a subdirectory.
Probably the main problem is that wmic is deprecated, as in Windows 10 features we’re no longer developing - Windows Deployment. We are supposed to use PowerShell instead, as in (in PowerShell):
Get-CimInstance -ClassName Win32_Product -Filter "Name like '.NET%'"
Except I do not know enough PowerShell to know how to write the output to a file.