2

I use following registry macro to add a contextual menu on .XML file

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\xmlfile\shell\FormatXML]
@="Format-XML"

[HKEY_CLASSES_ROOT\xmlfile\shell\FormatXML\command]
@="D:\\Program Files (x86)\\Tools\\XFormat\\XFormat.bat %1"

Currently, I have received a new PC in Windows 7 and I run same Registry script to add explorer contextual menu. Now, when I check if menu is visible, I don't see anything !

I have modified my Registry script to define the same context using ".xml" instead of "xmlfile" but nothing happens.

I have then replace ".xml" by ".txml", I have changed the type of XML file to TXML and ... that's working.

What happens ?

How can I define an explorer context menu on XML file ?

My XML registry is following

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\.xml]
@="xmlfile"
"Content Type"="text/xml"
"PerceivedType"="text"

[HKEY_CLASSES_ROOT\.xml\OpenWithProgids]
"VisualStudio.xml.10.0"=""
"VisualStudio.xml.d25f0747"=""

[HKEY_CLASSES_ROOT\.xml\PersistentHandler]
@="{7E9D8D44-6926-426F-AA2B-217A819A5CCE}"

[HKEY_CLASSES_ROOT\.xml\shell]

[HKEY_CLASSES_ROOT\.xml\shell\FormatXML]
@="Format-XML"

[HKEY_CLASSES_ROOT\.xml\shell\FormatXML\command]
@="D:\\Program Files (x86)\\Tools\\XFormat\\XFormat.bat %1"

2 Answers 2

1

Old question, but since it bubbled to the top...

The most likely reason the edit failed is that it creates an entry where neither the path to the executable/bat as well as the fully qualified path of the argument (%1) are unquoted, and thus will fail when there are spaces in the path:

enter image description here

If the necessary quotation marks are added:

enter image description here

and the entry exported, the .reg file becomes:

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\xmlfile\shell\FormatXML\command]
@="\"D:\\Program Files (x86)\\Tools\\XFormat\\XFormat.bat\" \"%1\""


Note the escaped quotation marks.

There's rerely a need to compose a .reg file from scratch and worry about escape sequences when regedit can act as a WYSIWYG editor. Creating an entry in regedit and then editing the exported file is much easier if path modification or cloning to other ProgIDs is necessary.

1

Now, on Windows 10, the solution I'm using on my PC is following

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\SystemFileAssociations\.xml\shell\FORMAT-XML\command]
@="C:\\Script\\FORMAT-XML\\FORMAT-XML.bat \"%L\""

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .