Hello,
i want to let my batch file CMD set itself as the default opener for a certain extension.
Can anyone give me a code for this???
Hello,
i want to let my batch file CMD set itself as the default opener for a certain extension.
Can anyone give me a code for this???
Try right clicking on a file that has the extension, go to Open With -> Choose Program -> Select program from list. Browse for your batch file and check "Always use the selected program to open this kind of file".
You can use the assoc and ftype commands to create an association between your extension and any executable file, including your own batch file or script.
assoc .xyz=xyzfile
ftype xyzfile=HandleXYZ.cmd "%1"
where HandleXYZ.cmd in this case is essentially "type %1".
Then you can create an XYZ file, type the name at the command line, and they will be run by HandleXYZ.
C:\test>copy con testfile.xyz
this is an xyz file
^Z
C:\test>testfile.xyz
this is an xyz file
C:\test>
To have a batch file set itself as a handler for a filetype would be as easy as running the assoc and ftype commands, but it would generally only need to be done once.
Read the assoc and ftype command line help for useful info, then look in HKEY_CLASSES_ROOT to see the entries they make.
You could test the output of these programs to see if the association is already made, and reset it if not, or if different.
What is your batch file doing that makes sense for it to set itself as its own handler?