I learnt that I can use NUL> but it is working strangely. Whenever I use it, it reports "Access is denied" but the file is created.
You're getting access denied since you're trying to run the nul
device (whether you redirect standard output or not is irrelevant):
c:\pax> nul
Access is denied.
c:\pax> nul >myfile.txt
Access is denied.
What you need to do to get an empty file, although there are other ways to do it, is send the output of the nul
device to your file, with something like:
c:\pax> type nul >myfile.txt
c:\pax> dir myfile.txt
Volume in drive C has no label.
Volume Serial Number is DEAD-BEEF
Directory of c:\pax
21/06/2018 04:57 PM 0 myfile.txt
1 File(s) 0 bytes
0 Dir(s) 31,415,926,535,902,718,281,828,459 bytes free
Only that first line above is needed to create an empty file, the rest is just to show that it worked.