如何为所有用户安装程序快捷方式?

发布于 2024-07-17 06:44:46 字数 164 浏览 6 评论 0原文

我正在使用 Windows Installer XML 工具包创建安装程序 msi 文件。 安装创建的 msi 文件时,放置在 ProgramMenuFolder 文件夹下的快捷方式将产生仅供管理员用户使用的快捷方式。 如何让安装程序在“所有用户”配置文件下创建快捷方式,以便计算机上的每个人都拥有该快捷方式?

I'm creating an installer msi file using the Windows Installer XML toolkit. When installing the created msi file, a shortcut placed under the ProgramMenuFolder folder results in a shortcut for the Administrator user only. How do I let the installer create a shortcut under the All Users profile, so that everyone on the machine has the shortcut?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

伤痕我心 2024-07-24 06:44:46

Package 元素 中,添加一个 InstallScope 属性,如下所示:

InstallScope='perMachine'

In the Package element, add an InstallScope attribute like this:

InstallScope='perMachine'
南笙 2024-07-24 06:44:46

基于 WIX 教程中的 SampleFirst.wxs http://www.tramontana.co.hu /wix/lesson1.php 我更改了两部分。

首先,添加属性 ALLUERS = 1 ""。 正如其他人所指出的,这将安装所有用户配置文件的快捷方式。

其次,将组件“ProgramMenuDir”的注册表值的根更改为 HKMU。 安装程序将根据 ALLUSERS 属性决定在安装时是否应使用 HKLM(本地计算机)或 HKCU(当前用户)。

然后,您应该能够添加对话框来修改 ALLUSERS 属性,注册表根目录也会相应更改。

<?xml version="1.0" encoding="utf-8"?>
<!-- Original Source available at "http://www.tramontana.co.hu/wix/download.php?file=samples/samplefirst.zip&type=application/zip" 
  This version has been modified for a local machine install (all users) vs a user install-->
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
    <Product Name="Foobar 1.0" Id="YOURGUID-CD32-4B20-BB4F-58A5C3B21A7C" UpgradeCode="YOURGUID-EDCE-42A2-9DA2-59FB08AC4FA6" Language="1033" Codepage="1252" Version="1.0.0" Manufacturer="Acme Ltd.">
        <Package Id="*" Keywords="Installer" Description="Acme's Foobar 1.0 Installer" Comments="Foobar is a registered trademark of Acme Ltd." Manufacturer="Acme Ltd." InstallerVersion="100" Languages="1033" Compressed="yes" SummaryCodepage="1252" />
        <Media Id="1" Cabinet="Sample.cab" EmbedCab="yes" DiskPrompt="CD-ROM #1" />
        <Property Id="DiskPrompt" Value="Acme's Foobar 1.0 Installation [1]" />
        <Property Id="ALLUSERS" Value="1" />
        <Directory Id="TARGETDIR" Name="SourceDir">
            <Directory Id="ProgramFilesFolder" Name="PFiles">
                <Directory Id="Acme" Name="Acme">
                    <Directory Id="INSTALLDIR" Name="Foobar 1.0">
                        <Component Id="MainExecutable" Guid="YOURGUID-2191-4A98-806B-2554B0DD8FC3">
                            <File Id="FoobarEXE" Name="FoobarAppl10.exe" DiskId="1" Source="FoobarAppl10.exe" KeyPath="yes">
                                <Shortcut Id="startmenuFoobar10" Directory="ProgramMenuDir" Name="Foobar 1.0" WorkingDirectory="INSTALLDIR" Icon="Foobar10.exe" IconIndex="0" Advertise="yes" />
                                <Shortcut Id="desktopFoobar10" Directory="DesktopFolder" Name="Foobar 1.0" WorkingDirectory="INSTALLDIR" Icon="Foobar10.exe" IconIndex="0" Advertise="yes" />
                            </File>
                        </Component>
                        <Component Id="HelperLibrary" Guid="YOURGUID-7BA7-4BD1-90B9-C0DFC21674B1">
                            <File Id="HelperDLL" Name="Helper.dll" DiskId="1" Source="Helper.dll" KeyPath="yes" />
                        </Component>
                        <Component Id="Manual" Guid="YOURGUID-F60A-48D6-83FD-44ED01AA579A">
                            <File Id="Manual" Name="Manual.pdf" DiskId="1" Source="Manual.pdf" KeyPath="yes">
                                <Shortcut Id="startmenuManual" Directory="ProgramMenuDir" Name="Instruction Manual" Advertise="yes" />
                            </File>
                        </Component>
                    </Directory>
                </Directory>
            </Directory>
            <Directory Id="ProgramMenuFolder" Name="Programs">
                <Directory Id="ProgramMenuDir" Name="Foobar 1.0">
                    <Component Id="ProgramMenuDir" Guid="YOURGUID-2D4F-443F-9ADA-563DB3C1581F">
                        <RemoveFolder Id="ProgramMenuDir" On="uninstall" />
                        <RegistryValue Root="HKMU" Key="Software\[Manufacturer]\[ProductName]" Type="string" Value="" KeyPath="yes" />
                    </Component>
                </Directory>
            </Directory>
            <Directory Id="DesktopFolder" Name="Desktop" />
        </Directory>
        <Feature Id="Complete" Level="1">
            <ComponentRef Id="MainExecutable" />
            <ComponentRef Id="HelperLibrary" />
            <ComponentRef Id="Manual" />
            <ComponentRef Id="ProgramMenuDir" />
        </Feature>
        <Icon Id="Foobar10.exe" SourceFile="FoobarAppl10.exe" />
        <UI />
    </Product>
</Wix>

Based on the SampleFirst.wxs in the WIX Tutorial http://www.tramontana.co.hu/wix/lesson1.php there were two parts that I changed.

First, add the property ALLUERS = 1 "". That installs the shortcut to the all users profile as others have noted.

Second, change the root for the registry value for Component 'ProgramMenuDir' to HKMU. The installer will decide if it should use HKLM (Local Machine) or HKCU (Current User) at install time, based on the on the ALLUSERS property.

You should then be able to add dialogs to modify the ALLUSERS property, with the registry root changing accordingly.

<?xml version="1.0" encoding="utf-8"?>
<!-- Original Source available at "http://www.tramontana.co.hu/wix/download.php?file=samples/samplefirst.zip&type=application/zip" 
  This version has been modified for a local machine install (all users) vs a user install-->
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
    <Product Name="Foobar 1.0" Id="YOURGUID-CD32-4B20-BB4F-58A5C3B21A7C" UpgradeCode="YOURGUID-EDCE-42A2-9DA2-59FB08AC4FA6" Language="1033" Codepage="1252" Version="1.0.0" Manufacturer="Acme Ltd.">
        <Package Id="*" Keywords="Installer" Description="Acme's Foobar 1.0 Installer" Comments="Foobar is a registered trademark of Acme Ltd." Manufacturer="Acme Ltd." InstallerVersion="100" Languages="1033" Compressed="yes" SummaryCodepage="1252" />
        <Media Id="1" Cabinet="Sample.cab" EmbedCab="yes" DiskPrompt="CD-ROM #1" />
        <Property Id="DiskPrompt" Value="Acme's Foobar 1.0 Installation [1]" />
        <Property Id="ALLUSERS" Value="1" />
        <Directory Id="TARGETDIR" Name="SourceDir">
            <Directory Id="ProgramFilesFolder" Name="PFiles">
                <Directory Id="Acme" Name="Acme">
                    <Directory Id="INSTALLDIR" Name="Foobar 1.0">
                        <Component Id="MainExecutable" Guid="YOURGUID-2191-4A98-806B-2554B0DD8FC3">
                            <File Id="FoobarEXE" Name="FoobarAppl10.exe" DiskId="1" Source="FoobarAppl10.exe" KeyPath="yes">
                                <Shortcut Id="startmenuFoobar10" Directory="ProgramMenuDir" Name="Foobar 1.0" WorkingDirectory="INSTALLDIR" Icon="Foobar10.exe" IconIndex="0" Advertise="yes" />
                                <Shortcut Id="desktopFoobar10" Directory="DesktopFolder" Name="Foobar 1.0" WorkingDirectory="INSTALLDIR" Icon="Foobar10.exe" IconIndex="0" Advertise="yes" />
                            </File>
                        </Component>
                        <Component Id="HelperLibrary" Guid="YOURGUID-7BA7-4BD1-90B9-C0DFC21674B1">
                            <File Id="HelperDLL" Name="Helper.dll" DiskId="1" Source="Helper.dll" KeyPath="yes" />
                        </Component>
                        <Component Id="Manual" Guid="YOURGUID-F60A-48D6-83FD-44ED01AA579A">
                            <File Id="Manual" Name="Manual.pdf" DiskId="1" Source="Manual.pdf" KeyPath="yes">
                                <Shortcut Id="startmenuManual" Directory="ProgramMenuDir" Name="Instruction Manual" Advertise="yes" />
                            </File>
                        </Component>
                    </Directory>
                </Directory>
            </Directory>
            <Directory Id="ProgramMenuFolder" Name="Programs">
                <Directory Id="ProgramMenuDir" Name="Foobar 1.0">
                    <Component Id="ProgramMenuDir" Guid="YOURGUID-2D4F-443F-9ADA-563DB3C1581F">
                        <RemoveFolder Id="ProgramMenuDir" On="uninstall" />
                        <RegistryValue Root="HKMU" Key="Software\[Manufacturer]\[ProductName]" Type="string" Value="" KeyPath="yes" />
                    </Component>
                </Directory>
            </Directory>
            <Directory Id="DesktopFolder" Name="Desktop" />
        </Directory>
        <Feature Id="Complete" Level="1">
            <ComponentRef Id="MainExecutable" />
            <ComponentRef Id="HelperLibrary" />
            <ComponentRef Id="Manual" />
            <ComponentRef Id="ProgramMenuDir" />
        </Feature>
        <Icon Id="Foobar10.exe" SourceFile="FoobarAppl10.exe" />
        <UI />
    </Product>
</Wix>
離人涙 2024-07-24 06:44:46

Stuart Preston 的博客很好地描述了如何执行此操作:

为“所有用户”安装快捷方式(通过 Wayback Machine)

编辑:

概要是:

在您的 .wxs 文件中,包含以下内容:

<属性 Id="ALLUSERS"> 
  

这将预设一个模仿选择行为的属性
安装时选择“所有用户”而不是“只有我”。 你会
也需要类似于以下的目录结构:

<目录 Id='ProgramMenuFolder' Name='PMenu' LongName='Programs'> 
  <目录 Id='MyProductShortcutDir' Name='MyPMenu' LongName='MyProduct' /> 
   
  

最后,您的快捷方式应该位于“File”元素内,如下所示:

<文件 ID="MyProduct.File0" LongName="MyProduct.exe" Name="MYPROD_1.EXE" src="c:\MyProductSourceFolder\MyProduct.exe" > 
  <快捷方式 Id="MyProduct.Shortcut" Directory="MyProductShortcutDir" Name="MPSCUT" LongName="我的产品快捷方式" />>  
   
  

Stuart Preston's blog has a good description of how to do this:

Installing a shortcut for "All Users" (via Wayback Machine)

Edit:

The synopsys is:

In your .wxs file, include the following:

<Property Id="ALLUSERS"><![CDATA[2]]></Property>

This will preset a property which mimics the behaviour of selecting
the "All Users" rather than "Just Me" for your installation. You'll
need a directory structure similar to the following too:

<Directory Id='ProgramMenuFolder' Name='PMenu' LongName='Programs'>
<Directory Id='MyProductShortcutDir' Name='MyPMenu' LongName='MyProduct' />
</Directory>

Finally, your shortcut should be within a "File" element, as follows:

<File Id="MyProduct.File0" LongName="MyProduct.exe" Name="MYPROD_1.EXE" src="c:\MyProductSourceFolder\MyProduct.exe" >
<Shortcut Id="MyProduct.Shortcut" Directory="MyProductShortcutDir" Name="MPSCUT" LongName="My Product Shortcut" /> 
</File>
桃扇骨 2024-07-24 06:44:46

鲍勃·阿恩森有一个博客文章,介绍如何在 Wix 中设置用户与机器。
快速的答案是将 Package 元素的 InstallScope 属性设置为“perMachine”。

Bob Arnson has a blog entry that covers how to set User vs. Machine in Wix.
The quick answer is to set the Package element's InstallScope attribute to "perMachine".

梦纸 2024-07-24 06:44:46

简单定义 ALLUSERS=1 即可强制按机器安装。

  <Property Id="ALLUSERS"><![CDATA[1]]></Property>

Simple define ALLUSERS=1 to force a per-machine installation.

  <Property Id="ALLUSERS"><![CDATA[1]]></Property>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文