Create setup that run without admin privileges using VS 2015 Professional - winforms

I'm trying to create a setup file (MSI) that runs without admin privileges. for that, I've tried the bellow option.
I've set InstallAlluser property to false as bellow.
Also set InstallAllUsersVisible to false
I've also changed Default location with [AppDataFolder]
After changes above properties It still required Administrator permission to execute MSI file that created using Setup project.
Can you please help me to resolve this issue.
Thanks in Advance.

When you open your MSI with Orca (or equivalent MSI viewer), do you see the "UAC Compliant" check box checked? Sample screenshot here:
You should really use a more flexible and capable MSI tool than the Visual Studio Installer projects. They are good for a few purposes, but lack flexibility and there are numerous other problems: summary of VS Project problems (short form).
Per-User setups considered harmful: Some words of warning against per user setups. Here is one more answer on that.
A simple per-user folder installation in WiX (insert UPPERCASE GUIDs in locations shown with "PUT-GUID-HERE" (2 occurrences) - you can use this GUID generator):
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="*" Name="PerUserSample" Language="1033" Version="1.0.0.0" Manufacturer="-" UpgradeCode="PUT-GUID-HERE">
<Package InstallerVersion="200" Compressed="yes" InstallScope="perUser" InstallPrivileges="limited" />
<MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
<MediaTemplate EmbedCab="yes" />
<UIRef Id="WixUI_Mondo" />
<Feature Id="ProductFeature" Title="PerUserSample" Level="1" />
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="AppDataFolder">
<Directory Id="Something" Name="Something">
<Component Feature="ProductFeature" Guid="PUT-GUID-HERE">
<RegistryValue Root="HKCU" Key="Software\[Manufacturer]\[ProductName]\Test"
Name="installed" Type="integer" Value="1" KeyPath="yes"/>
<File Source="C:\Windows\Notepad.exe" />
<RemoveFolder Id="Something" Directory="Something" On="uninstall" />
</Component>
</Directory>
</Directory>
<Directory Id="ProgramFilesFolder">
<Directory Id="INSTALLFOLDER" Name="PerUserSample" />
</Directory>
</Directory>
</Product>
</Wix>

Related

WiX toolset CNDL0001 Invalid URI when compiling

I'm running into an issue with an invalid URI when attempting to run the Wix V3.11.2 toolset via Powershell. I'm not sure what is causing the error.
Full error:
$ candle.exe Product.wxs
Windows Installer XML Toolset Compiler version 3.11.2.4516
Copyright (c) .NET Foundation and contributors. All rights reserved.
Product.wxs
candle.exe : error CNDL0001 : Invalid URI: The hostname could not be parsed.
Exception Type: System.UriFormatException
Stack Trace:
at System.Uri.CreateThis(String uri, Boolean dontEscape, UriKind uriKind)
at System.Uri..ctor(String uriString)
at Microsoft.Tools.WindowsInstallerXml.Preprocessor.Process(String sourceFile, Hashtable variables)
at Microsoft.Tools.WindowsInstallerXml.Tools.Candle.Run(String[] args)
The test file I'm using:
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="*"
Name="My Software"
Language="1033"
Manufacturer="My Company"
Version="1.0.0.0"
UpgradeCode="GUID-HERE">
<Package InstallerVersion="200"
Compressed="yes"
InstallScope="perMachine" />
<MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
<MediaTemplate EmbedCab="yes" />
<Feature Id="ProductFeature"
Title="The main feature"
Level="1">
<ComponentGroupRef Id="ProductComponents" />
</Feature>
</Product>
</Wix>
I replaced the UpgradeCode with a placeholder for this post; a unique code
is there when I run it. I've tried installing via the download button from the official site, installing via github exe download, and installing via dotnet tool install. All 3 instances give me the same error. I'm hoping I'm missing something simple.
Figured it out. Turns out, that is the error message received if the .NET installation is the wrong version, but WiX ends up being installed anyways. For WiX V3.11, the .NET 3.5 framework is needed.

Wix - conditionally install a file to C:\MyConfig folder

I want to install a configuration file from my Wix setup project to C: drive, MyConfig folder.
I have a hard time to specify C:\ in directory, as the character ":" is not permitted in the attribute "Name".
Also I would like the file to be installed conditionally, and in such a way that is NOT removed during uninstall.
After some trial and error I found the answer. I just need to simply add SetDirectory element that will override my C Drive directory, like that.
<PropertyRef Id="ENV_DEPLOY"/>
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder">
<Directory Id="CompanyName" Name="!(bind.property.Manufacturer)">
<Directory Id="INSTALLFOLDER" Name="!(bind.property.ProductName)" />
</Directory>
</Directory>
<Directory Id="CDrive" Name="CDrive">
<Directory Id="ConfigDir" Name="MyConfig" />
</Directory>
</Directory>
<SetDirectory Id="CDrive" Value="C:\" />
<ComponentGroup Id="EnvironmentSetup" Directory="ConfigDir" >
<Component Id="currentEnvironment_DEVELOPMENT" Guid="*" Permanent="yes" >
<Condition>ENV_DEPLOY="DEVELOPMENT"</Condition>
<File Id="ConfigFile_DEVELOPMENT" Source="DEVELOPMENT\currentEnvironment.config" />
</Component>
<Component Id="currentEnvironment_PRODUCTION" Guid="*" Permanent="yes" >
<Condition>ENV_DEPLOY="PRODUCTION"</Condition>
<File Id="ConfigFile_PRODUCTION" Source="PRODUCTION\currentEnvironment.config" />
</Component>
</ComponentGroup>
I know you just want an answer, but please consider other solution options. This construct fights the Windows Installer design, and I can guarantee you it will fight back. This fight is not worth it. All of Windows Installer is designed to not allow such unusual (and unnecessary) deployment constructs. There must be alternatives.
Why do you want to access the C:\Config folder? We really need to know to understand what you want to achieve. This is an internal system folder for the Windows Installer engine. It generally stores rollback files for any running MSI installs. I can't think of a single reason to do anything in this folder at all - it is just not safe.

Error 0x80004005 when I tried to install a database with WIX

I'm trying to install a database with WIX.
I've already installed SQL Server 2008 express on my Windows7 (32 Bit). On this installation, TCP/IP is enabled, SQL Server service is running.
I'm using SQL Server and Windows authentication for SQL Server. I tried both in the code - I added a user in the component.
The code is very basic :
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"
xmlns:sql="http://schemas.microsoft.com/wix/SqlExtension">
<Product Id="*" Name="NewDatabaseInstaller" Language="1033"
Version="1.0.0.0" Manufacturer="My Company"
UpgradeCode="17ef693b-3ab5-4788-a6b5-70eeabc13497">
<Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />
<MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
<MediaTemplate EmbedCab="yes" />
<Feature Id="ProductFeature" Title="NewDatabaseInstaller" Level="1">
<ComponentGroupRef Id="ProductComponents" />
</Feature>
</Product>
<Fragment>
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder">
<Directory Id="INSTALLFOLDER" Name="NewDatabaseInstaller" />
</Directory>
</Directory>
</Fragment>
<Fragment>
<ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER">
<Component Id="cmpSqlDatabase" Guid="{F950605D-AA59-43E6-AB19-9452F6BEC649}" KeyPath="yes">
<sql:SqlDatabase Id="sqlDatabase_MyDatabase" Server="localhost"
Instance="MSSQLSERVER" Database="MyDatabase"
CreateOnInstall="yes" DropOnUninstall="yes"
ContinueOnError="no" />
</Component>
</ComponentGroup>
</Fragment>
</Wix>
I had the instance name by taping this query in the Management studio :
SELECT ##servicename
However, I get an error :
CreateDatabase: Error 0x80004005: failed to create to database: 'MyDatabase', error: unknown error
Error 26201. Error -2147467259: failed to create SQL database: MyDatabase, error detail: unknown error.
MSI (s) (FC!74) [17:43:27:786]: Product: Test -- Error 26201. Error -2147467259: failed to create SQL database: MyDatabase, error detail: unknown error.
CustomAction CreateDatabase returned actual error code 1603 (note this may not be 100% accurate if translation happened inside sandbox)
Action ended 17:43:27: InstallFinalize. Return value 3.
Did I miss something?
Thanks !
I found my problem.
I'm ashamed of my error : I put a instance
Instance="MSSQLSERVER"
I did not need it. I thought it was the
SELECT ##servicename
So, I don't know when we need it... Did someone know?
Thanks Yan for your help!

SQL Server Project Automate Unit Testing

I have a SQL Server (2012) project in VS2013. I also have an app.config with Local configuration and [tfsbuildserver].sqlunittest.config with server connection string and a relative path.
When performing a check-in executes a build definition that makes deploy and run the tests. The deploy done correctly, but when tests throws me the following error:
An error occurred while SQL Server unit testing settings were being read from the configuration file. Click the test project, open the
SQL Server Test Configuration dialog box from the SQL menu, add the
settings to the dialog box, and rebuild the project.
app.config:
<configuration>
<configSections>
<section name="SqlUnitTesting" type="Microsoft.Data.Tools.Schema.Sql.UnitTesting.Configuration.SqlUnitTestingSection, Microsoft.Data.Tools.Schema.Sql.UnitTesting, Version=12.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
</configSections>
<SqlUnitTesting AllowConfigurationOverride="true">
<DatabaseDeployment DatabaseProjectFileName="[RELATIVEPATHLOCAL]"
Configuration="Release" />
<DataGeneration ClearDatabase="true" />
<ExecutionContext Provider="System.Data.SqlClient" ConnectionString="Data Source=[LOCALSERVER];Initial Catalog=[DATABASE];Integrated Security=True;Pooling=False"
CommandTimeout="30" />
<PrivilegedContext Provider="System.Data.SqlClient" ConnectionString="Data Source=[LOCALSERVER];Initial Catalog=[DATABASE];Integrated Security=True;Pooling=False"
CommandTimeout="30" />
</SqlUnitTesting>
</configuration>
[tfsbuildserver].sqlunittesting.config:
<SqlUnitTesting>
<DatabaseDeployment DatabaseProjectFileName="[RELATIVEPATHTFS]"
Configuration="Release" />
<DataGeneration ClearDatabase="true" />
<ExecutionContext Provider="System.Data.SqlClient" ConnectionString="Data Source=[SERVERTEST];Initial Catalog=[DATABASETEST];Persist Security Info=True;User ID=[USER];Password=[PASS];Pooling=False"
CommandTimeout="30" />
<PrivilegedContext Provider="System.Data.SqlClient" ConnectionString="Data Source=[SERVERTEST];Initial Catalog=[DATABASETEST];Persist Security Info=True;User ID=[USER];Password=[PASS];Pooling=False"
CommandTimeout="30" />
</SqlUnitTesting>
Tests run correctly locally. The error occurs when performing the build definition
Sorry for my English.
Thanks
Turns out the issue was that I had leading white space before the <SqlUnitTesting>, once these were removed the test ran as expected and remove
<?xml version="1.0" encoding="utf-8" ?>
URL: Link Resolved

How do you recursively apply file permissions to an existing folder using a Wix installer?

We have an installer created using Wix 3.5 for our application. We have users of our application that have existing data in the Common Application Data Folder that we would like to "fix" the permissions on so that our users no longer need to be Administrators on their PCs.
So during the install I added the following section to the Wix Project so that it modifies our folders permissions. This works great for new users, but any existing files in those folders still retain the old ACL and don't allow non-admin users to read/modify them.
<Directory Id="CommonAppDataFolder">
<Directory Id="CommonAppOurCompany" Name="OurCompany">
<Directory Id="MODELLIBPATH" Name="Library">
<Component Id="LibraryUserPermissions" Guid="12BC499B-4601-449F-9515-4C58A8F29603">
<CreateFolder>
<util:PermissionEx GenericRead="yes" GenericWrite="yes" GenericExecute="yes" Delete="yes" DeleteChild="yes" User="Users" Domain="[MachineName]"/>
</CreateFolder>
</Component>
</Directory>
</Directory>
</Directory>
What can I do to recursively apply the new ACL to each file in the folder and its subfolders, without deleting or modifying the files (other than their security settings)?
Normally an installer creates and sets the permissions so that new folders and files will inherit. In your situation you'll need to write a custom action to call cacls or similar to recursive the structure and apply the permissions. There's no built in ability in MSI or WiX to do this to the best of my knowledge.
Folder permission:
<ComponentGroup Id="" Directory="" Source="">
<Component Id="CompID" Guid="*">
<CreateFolder>
<Permission User="Administrators" GenericAll="yes"/>
<Permission User="Users" GenericAll="no" GenericRead="yes" GenericExecute="yes"/>
<---- keep adding required user permission --->
</CreateFolder>
File Permission:
Little tricky. I tried using Cacl.exe in Customaction but did not help. First you need to remove existing file to clear existing ACL then create new file:
<RemoveFile Id="fileID" Name="FileName" On="both" />
<File Id ="fileID" KeyPath="yes">
<Permission User="Administrators" GenericAll="yes"/>
<Permission User="Users" GenericAll="no" GenericRead="yes" GenericExecute="yes" GenericWrite="no"/>
</File>
</Component>
</ComponentGroup>

Resources