Create MSI and Enforce All Users with Visual Studi

2019-01-20 16:46发布

问题:

I have created an installer using Visual Studio 2015 (with the Visual Studio installer addon). The goal is to always run the APP with the same local resources, regardless of who is logged on, therefore we target [CommonAppDataFolder] (C:\ProgramData... on Win10). The installer works just fine placing all shared resources where we want them. But the generated MSI provides the option to install as "everyone" or just the "just me"

We want to grey out the option to install as "just me". Is there a way to do this from within Visual Studio as part of the build process for the MSI.

I see some solutions that involve running MSIEXEC with different parms eg, ALLUSERS, but I am wondering if there is a way to set this up to occur automatically in Visual Studio.

Thank you.

回答1:

The project Properties window (NOT properties) can be shown by selecting the project in Solution Explorer, and then F4. You can set InstallAllUsers to True there.

The Properties window of the InstallFolder dialog has a settting InstallAllUsersVisible, so just set that to False.



回答2:

I don't use that particular tool. There might be a better way to achieve what you want than the below "hack". Adding since you got no other answers (yet).

UPDATE: Go with Phil's answer. I don't have the tool to check but it looks good. Leaving in this answer just for the record. Not recommended unless you have other things you want to change.

Post-Process MSI

Hiding Control: Not ideal, but if you don't mind post-processing the MSI (can be automated with MSI API coding) you could insert a row into the ControlCondition table to hide the whole dialog control in question.

Ad-hoc sample: Hiding the "Back" button from a setup's LicenseAgreementDlg - just add this row (I guess events defined elsewhere could show it again):

.


Dialog at runtime: Below is the actual dialog at runtime.


MSI API

To automate the above. Get hold of WiRunSQL.vbs - part of the Windows SDK - just search your SDK folder if you have Visual Studio installed. Also plenty of copies on github.

In a batch file:

cscript.exe "%~dp0"\WiRunSQL.vbs "MySetup.msi" "INSERT INTO `ControlCondition` (`Dialog_`, `Control_`, `Action`, `Condition`) VALUES ('LicenseAgreementDlg', 'Back', 'Hide', '1')"    
pause

I honestly might hard code ALLUSERS=1 in the Property table as well.