Msiexec a MSI package with passive got different results in administrator command prompt and normal command prompt

huangapple go评论53阅读模式
英文:

Msiexec a MSI package with passive got different results in administrator command prompt and normal command prompt

问题

我尝试创建一个MSI包来 passively 在标准用户帐户中进行安装。这个MSI复制文件,写入HKCU注册表,创建%LOCALAPPDATA%下的文件夹,并在桌面上创建快捷方式,如下所示。

以下是WXS中的一部分代码:

<Directory Id="TARGETDIR" Name="SourceDir">
    <Directory Id="ProgramFiles64Folder">
        <Directory Id="INSTALLDIR" Name="Hello RMA">
            <!-- 其他组件和文件 -->
            <Component Id="Mode" Guid="{0ee73a0b-a204-4e0f-a604-8057f69ad837}" Win64="yes">
                <RegistryValue Id="Mode" Root="HKCU" Key="Software\Hello RMA" Name="Mode" Value="Tablet" Type="string" KeyPath="yes" />
            </Component>
            <Directory Id="Application_Dir" Name="Application">
                <!-- 其他组件和文件 -->
                <Component Id="HelloRMA.exe" Guid="{b973cdcc-d9e5-4cd2-903a-7e8886504833}" Win64="yes">
                    <!-- 文件和快捷方式信息 -->
                    <Shortcut Id="HelloRMA.exe_1" Directory="DesktopFolder" Name="Hello RMA" Target="[#HelloRMA.exe]" Description="Hello RMA.exe" Hotkey="0" IconIndex="0" Show="normal" WorkingDirectory="Application_Dir" />
                    <RegistryValue Root="HKCU" Key="Software\Hello RMA" Name="UI installed" Value="1" Type="string" KeyPath="yes" />
                </Component>
            </Directory>
        </Directory>
    </Directory>
    <Directory Id="DesktopFolder" Name="DesktopFolder" />
    <!-- 其他目录定义 -->
</Directory>

当在普通命令提示符下使用以下命令并提示凭据时,它可以正常运行:

msiexec /i rma.msi /passive

如果在管理员命令提示符下运行相同的命令,则注册表、%LOCALAPPDATA%中的文件夹和快捷方式不会被安装,只有文件被复制到INSTALLDIR。可能是由于权限问题导致的。您的WXS文件本身看起来没有问题。

另一个问题是,如果通过SCCM部署MSI到用户PC,它将在用户的上下文中执行,而不是管理员命令提示符或普通命令提示符下执行。这意味着它将以用户的权限和环境中运行,不会使用管理员权限。

英文:

I tried to make up wxs to build a MSI package. The target is to passive install in Standard User account. This MSI copies files, writes HKCU registry, creates folder under %LOCALAPPDATA% and creates a shortcut on desktop, as follows.

&lt;Directory Id=&quot;TARGETDIR&quot; Name=&quot;SourceDir&quot;&gt;
 &lt;Directory Id=&quot;ProgramFiles64Folder&quot;&gt;
	&lt;Directory Id=&quot;INSTALLDIR&quot; Name=&quot;Hello RMA&quot;&gt;
	   &lt;Component Id=&quot;files&quot; Guid=&quot;{0f8e0c9f-5248-4a88-90a3-8f08564bf7b9}&quot;&gt;...&lt;/Component&gt;
   
	   &lt;Component Id=&quot;Mode&quot; Guid=&quot;{0ee73a0b-a204-4e0f-a604-8057f69ad837}&quot; Win64=&quot;yes&quot;&gt;
			&lt;RegistryValue Id=&quot;Mode&quot; Root=&quot;HKCU&quot; Key=&quot;Software\Hello RMA&quot; Name=&quot;Mode&quot; Value=&quot;Tablet&quot; Type=&quot;string&quot; KeyPath=&quot;yes&quot; /&gt;
	   &lt;/Component&gt;
	   &lt;Directory Id=&quot;Application_Dir&quot; Name=&quot;Application&quot;&gt;
		   &lt;Component Id=&quot;chrome_100_percent.pak&quot; Guid=&quot;{eec8284f-d402-490a-a017-91f42779c848}&quot;&gt;
				&lt;File ... /&gt;
				...
		   &lt;/Component&gt;				   			
		   &lt;Component Id=&quot;HelloRMA.exe&quot; Guid=&quot;{b973cdcc-d9e5-4cd2-903a-7e8886504833}&quot; Win64=&quot;yes&quot;&gt;
				&lt;File Id=&quot;HelloRMA.exe&quot; Name=&quot;Hello RMA.exe&quot; Vital=&quot;no&quot; DiskId=&quot;1&quot; Source=&quot;payload\Application\Hello RMA.exe&quot; /&gt;
				&lt;Shortcut Id=&quot;HelloRMA.exe_1&quot; Directory=&quot;DesktopFolder&quot; Name=&quot;Hello RMA&quot; Target=&quot;[#HelloRMA.exe]&quot; Description=&quot;Hello RMA.exe&quot; Hotkey=&quot;0&quot; IconIndex=&quot;0&quot; Show=&quot;normal&quot; WorkingDirectory=&quot;Application_Dir&quot; /&gt;
				&lt;RegistryValue Root=&quot;HKCU&quot; Key=&quot;Software\Hello RMA&quot; Name=&quot;UI installed&quot; Value=&quot;1&quot; Type=&quot;string&quot; KeyPath=&quot;yes&quot; /&gt;
		   &lt;/Component&gt;				   
	   &lt;/Directory&gt;
	&lt;/Directory&gt;
 &lt;/Directory&gt;
 &lt;Directory Id=&quot;DesktopFolder&quot; Name=&quot;DesktopFolder&quot; /&gt;
 
 &lt;!-- Create folders in AppData --&gt;
 &lt;Directory Id=&quot;LocalAppDataFolder&quot; Name=&quot;LocalAppDataFolder&quot;&gt;
	&lt;Directory Id=&quot;HelloRMA_Dir&quot; Name=&quot;Hello RMA&quot;&gt;
		&lt;Directory Id=&quot;NewFolder_Dir&quot; Name=&quot;log&quot;&gt;
			&lt;Component Id=&quot;NewFolder&quot; Guid=&quot;{7afcd67e-079b-4619-8430-f4ee7ef41275}&quot;&gt;
				&lt;CreateFolder Directory=&quot;NewFolder_Dir&quot; /&gt;
				&lt;RegistryValue Root=&quot;HKCU&quot; Key=&quot;Software\Hello RMA&quot; Name=&quot;Log folder installed&quot; Value=&quot;1&quot; Type=&quot;string&quot; KeyPath=&quot;yes&quot; /&gt;
				&lt;RemoveFolder Id=&quot;RemoveLogDir&quot; Directory=&quot;NewFolder_Dir&quot; On=&quot;uninstall&quot; /&gt;
				&lt;RemoveFolder Id=&quot;RemoveRMADir&quot; Directory=&quot;HelloRMA_Dir&quot; On=&quot;uninstall&quot; /&gt;							
			&lt;/Component&gt;
		&lt;/Directory&gt;				
	&lt;/Directory&gt;
 &lt;/Directory&gt;

</Directory>

It works well when running it with the following command under normal command prompt with prompt for credentials.

msiexec /i rma.msi /passive

If running the same command under administrator command prompt, registry, folders in %LOCALAPPDATA% and shortcut would not be installed. Only files were copied to INSTALLDIR.
Why are they different? Anything wrong in my WXS?

Another question is I wonder if MSI is deployed to user PC by SCCM. What environment will it be executed? Administrator command prompt or normal command prompt?
Thanks.

答案1

得分: 0

一个冗长的日志文件肯定会告诉你。然而,我敢打赌,缺失的文件和注册表键仍在安装,但安装到了不同的用户配置文件中,你没有查看。

你列出的所有资源作为“missing”都安装到了用户配置文件(LocalAppDataFolderHKCU),因此它们将安装到启动安装的用户配置文件中。

所以我猜测你的提权命令提示符正在以不同的用户身份运行,而不是你正常的命令提示符。

英文:

A verbose log file would tell you for sure. However, I bet the missing files and registry keys are still being installed but installed into a different user profile where you are not looking.

All the resources you list as "missing" are installed to the user profile (LocalAppDataFolder and HKCU), so they will be installed to the user profile that launched the install.

So my guess is that your elevated command prompt is running as a different user than your normal command prompt.

huangapple
  • 本文由 发表于 2023年3月3日 21:44:29
  • 转载请务必保留本文链接:https://go.coder-hub.com/75627857.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定