I'm not sure if you are asking for help to create a bat file or if your code works?
Anyway, open a notepad file, type or cut and paste your code and save it as type "all files" and name it whatever.bat.
I use similar code to print directories in a file called (what else) printdir.bat I stuck this in my "sendto" directory and now I can right click on any directory and print it out with out going to a command prompt. The "CLS" just keeps things clean.
dir %1>\\server_name\printer_name:
cls
Good luck