脚本扩展关联到一个程序 [英] Script to associate an extension to a program

查看:213
本文介绍了脚本扩展关联到一个程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的客户与OpenOffice的一些工作站替代微软Office。我的程序使用.xml扩展名(使用开放格式)的文件导出到Excel和使用当前的关联程序打开它(使用的ShellExecute)

My customer is replacing MS Office with OpenOffice in some workstations. My program export a file to Excel using the .xml extension (using open format) and opens it using the current associated program (using ShellExecute)

的问题是,OpenOffice的不注册与它相关的.xml扩展

The problem is that OpenOffice does not register the .xml extension associated with it.

手动协会工作正常,但我想打一个.reg或东西轻易更改设置。

Manually association works fine, but I want to make a .reg or something to easily change the setting.

我期待在与已经取得的变化的PC注册表,但在

I'm looking in the registry in a PC with the change already made, but the

"HKEY_CLASSES_ROOT\.xml"

键没有任何引用的OpenOffice。

key does not have anything referencing OpenOffice.

在哪里存储的关联?我怎样才能使一个脚本来完成的工作?

Where is the association stored? How can I make a script to do the work?

推荐答案

真正的关联被存储在密钥HKEY_CLASSES_ROOT \\的.xml点。

The real association is stored in the key that "HKEY_CLASSES_ROOT\.xml" points to.

在我的机器上,该键的默认值说XMLFILE,最有可能的就是为你一样的。

On my machine, the default value of that key says "xmlfile", most likely that is the same for yours.

因此​​,让我们去HKEY_CLASSES_ROOT \\ XMLFILE。在那里,你可以看到(和更改)什么命令将被用来发射这种类型的文件:

So let's go to "HKEY_CLASSES_ROOT\xmlfile". There you can see (and change) what command is going to be used to launch that type of file:

HKEY_CLASSES_ROOT\xmlfile\shell\open\command

Windows使用这种重定向到多个文件扩展从而映射到相同的文件类型,并以相同的应用程序。

Windows uses this kind of redirection to map multiple file extensions to the same file type, and thus to the same application.

HKEY_CLASSES_ROOT \\ XMLFILE \\壳有类似于你可以做的文件什么是动词多个子项。同样,壳的默认值键决定这些动词如果您双击该文件被使用。在我而言,这是打开

Under "HKEY_CLASSES_ROOT\xmlfile\shell" there are multiple sub-keys that resemble the "verbs" of what you can do to the file. Again, the default value of the "shell" key decides which of these verbs is used if you double click the file. In my case this is "open".

结论:

通过这些知识,最简单的方法,使协会编写脚本是用regedit导出包含这种变化.reg文件,并将其与双击或应用到目标计算机:

With that knowledge, the easiest way to make an association scriptable is to use regedit to export a .reg file containing that change, and apply it to the target computer with a double click or:

regedit /s new_xml_association.reg

或者(如果你是XP或更高,知道你做什么)与覆盖当前值:

or (if you are on XP or higher and know what you do) overwrite the current value with:

reg add "HKEY_CLASSES_ROOT\xmlfile\shell\open\command" /ve /d "path\to\program %1"

在任何情况下,深入探讨了 REG ADD /?命令建议。第一个解决方案是安全的。

At any rate, a deeper look into reg add/? command is advised. The first solution is safer.

这篇关于脚本扩展关联到一个程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆