[wix-users] Right Click run as Administrator VS Programmatically starting as admin.

Harinatha Narisetty harinatha.narisetty at us.abb.com
Fri Jun 16 06:49:09 PDT 2017


That worked. Thank you so much.



-----Original Message-----
From: wix-users [mailto:wix-users-bounces at lists.wixtoolset.org] On Behalf Of Gerhard Matzen
Sent: Thursday, June 15, 2017 8:29 PM
To: WiX Toolset Users Mailing List <wix-users at lists.wixtoolset.org>
Subject: Re: [wix-users] Right Click run as Administrator VS Programmatically starting as admin.

Sorry, my original email is probably not very clear.

You cannot use:
      Process.GetCurrentProcess().MainModule.FileName

You must use:
     WixBundleSourceProcessPath - gets the source path of the bundle where originally executed. Will only be set when bundle is executing in the clean room.

See:
http://wixtoolset.org/documentation/manual/v3/bundle/bundle_built_in_variables.html


-----Original Message-----
From: wix-users [mailto:wix-users-bounces at lists.wixtoolset.org] On Behalf Of Harinatha Narisetty
Sent: Thursday, June 15, 2017 3:47 PM
To: WiX Toolset Users Mailing List <wix-users at lists.wixtoolset.org>
Subject: Re: [wix-users] Right Click run as Administrator VS Programmatically starting as admin.

var myInfo = new ProcessStartInfo
                             {
                                 FileName = Process.GetCurrentProcess().MainModule.FileName,
                                 UseShellExecute = true,
                                 WorkingDirectory = Environment.CurrentDirectory,
                                 Verb = "runas"
                             };
                Process.Start(myInfo);

Working directory was not there earlier.. I just added after reading your email... testing  it... Do you think it will help?


-----Original Message-----
From: wix-users [mailto:wix-users-bounces at lists.wixtoolset.org] On Behalf Of Gerhard Matzen
Sent: Thursday, June 15, 2017 6:43 PM
To: WiX Toolset Users Mailing List <wix-users at lists.wixtoolset.org>
Subject: Re: [wix-users] Right Click run as Administrator VS Programmatically starting as admin.

So, if you are trying to re-launch from 
	C:\Users\ushanar\AppData\Local\Temp\{4A0621B9-5F9B-4F37-AD2E-721DB8018D46}\.cr\Enerprise-Setup.exe
You will fail. 

That file is not the full exe.  It is a stub.  It does not include the source.

It also tells me that you don't have a resolvesource handler, but that is a different story.

-----Original Message-----
From: wix-users [mailto:wix-users-bounces at lists.wixtoolset.org] On Behalf Of Harinatha Narisetty
Sent: Thursday, June 15, 2017 3:39 PM
To: WiX Toolset Users Mailing List <wix-users at lists.wixtoolset.org>
Subject: Re: [wix-users] Right Click run as Administrator VS Programmatically starting as admin.

I am doing this already... I have this problem only when the setup is made using VSTS managed host which has exact version of wix that I have on on-premise build server.
When I right click and run as admin it works fine. The problem comes only when I double click the exe  and click on a button to open the same exe using elevated permissions. I see below error in log file.

[2368:101C][2017-06-15T15:00:59]i371: Updating session, registration key: SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{16d7ea68-fda1-4570-a1fc-456ed9f8568d}, resume: Active, restart initiated: No, disable resume: No
[2DAC:37F8][2017-06-15T15:00:59]w341: Prompt for source of container: WixAttachedContainer, path: C:\Users\ushanar\AppData\Local\Temp\{4A0621B9-5F9B-4F37-AD2E-721DB8018D46}\.cr\Enerprise-Setup.exe
[2DAC:37F8][2017-06-15T15:00:59]e054: Failed to resolve source for file: C:\Users\ushanar\AppData\Local\Temp\{4A0621B9-5F9B-4F37-AD2E-721DB8018D46}\.cr\Enerprise-Setup.exe, error: 0x80070002.
[2DAC:37F8][2017-06-15T15:00:59]e000: Error 0x80070002: Failed while prompting for source (original path 'C:\Users\ushanar\AppData\Local\Temp\{4A0621B9-5F9B-4F37-AD2E-721DB8018D46}\.cr\Enerprise-Setup.exe').

What is that third line telling ???

Thanks
Hari

-----Original Message-----
From: wix-users [mailto:wix-users-bounces at lists.wixtoolset.org] On Behalf Of Gerhard Matzen
Sent: Thursday, June 15, 2017 4:20 PM
To: WiX Toolset Users Mailing List <wix-users at lists.wixtoolset.org>
Subject: Re: [wix-users] Right Click run as Administrator VS Programmatically starting as admin.

Perhaps this code might help you.  This takes into account the clean room.

      public void RestartElevatedAndQuit(bool prompt)
      {
         if (prompt)
         {
            var message =
               $"The \"{Bundle.GetBundle().DisplayName}\" setup kit requires elevated permissions.{Environment.NewLine}{Environment.NewLine}Restart now with elevated credentials?";
            var result = ShowMessageDialog(message, MessageBoxButton.OKCancel, MessageBoxImage.Warning);
            if (result == MessageBoxResult.Cancel)
            {
               LogInfo("User has chosen to cancel setup without restarting with elevated permissions.");
               throw new RestartElevatedException();
            }
         }
         var environmentArgs = Environment.GetCommandLineArgs();
         var args = string.Join(" ", environmentArgs.Select(
            arg => arg.StartsWith("-burn.", StringComparison.InvariantCultureIgnoreCase) || arg == environmentArgs[0]
               ? string.Empty
               : arg.Any(char.IsWhiteSpace)
                    ? $"\"{arg}\""
                    : arg));

         string fileName, workingDirectory;
         if (TryGetWixBundleSourceProcessPath(out fileName))
         {
            LogInfo($"{nameof(Bundle.Variables.WixBundleSourceProcessFolder)} is defined.");
            workingDirectory = Bundle.Variables.WixBundleSourceProcessFolder;
         }
         else
         {
            LogInfo($"{nameof(Bundle.Variables.WixBundleSourceProcessFolder)} is not defined defined. Determining source from current process.");
            fileName = Process.GetCurrentProcess().MainModule.FileName;
            workingDirectory = Environment.CurrentDirectory;
         }
         LogInfo($"File: {fileName}. Working directory: {workingDirectory}.");

         var startInfo = new ProcessStartInfo
         {
            UseShellExecute = true,
            FileName = fileName,
            WorkingDirectory = workingDirectory,
            Verb = "runas",
            Arguments = args
         };
         try
         {
            Process.Start(startInfo);
         }
         catch (Win32Exception ex)
         {
            //1223 == "The operation was canceled by the user."
            //The cancel error occurs if the user says no to the UAC prompt.  
            if (ex.NativeErrorCode != 1223)
            {
               throw;
            }
         }
         throw new RestartElevatedException();
      }

-----Original Message-----
From: wix-users [mailto:wix-users-bounces at lists.wixtoolset.org] On Behalf Of Harinatha Narisetty
Sent: Thursday, June 15, 2017 1:09 PM
To: WiX Toolset Users Mailing List <wix-users at lists.wixtoolset.org>
Subject: Re: [wix-users] Right Click run as Administrator VS Programmatically starting as admin.

Ignore the size part... I figured that out.... Does the following message give any clue?

[2DAC:37C4][2017-06-15T15:00:55]i300: Apply begin
[2DAC:37C4][2017-06-15T15:00:55]i010: Launching elevated engine process.
[2DAC:37C4][2017-06-15T15:00:55]i011: Launched elevated engine process.
[2DAC:37C4][2017-06-15T15:00:55]i012: Connected to elevated engine.
[2368:101C][2017-06-15T15:00:56]i358: Pausing automatic updates.
[2368:101C][2017-06-15T15:00:56]i359: Paused automatic updates.
[2368:101C][2017-06-15T15:00:56]i360: Creating a system restore point.
[2368:101C][2017-06-15T15:00:56]w363: Could not create system restore point, error: 0x80070422. Continuing...
[2368:101C][2017-06-15T15:00:56]i370: Session begin, registration key: SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{16d7ea68-fda1-4570-a1fc-456ed9f8568d}, options: 0x7, disable resume: No
[2368:101C][2017-06-15T15:00:59]i000: Caching bundle from: 'C:\Users\ushanar\AppData\Local\Temp\{26D6D3E8-B2E7-4ABC-A464-CF3FA97CE905}\.be\Enerprise-Setup.exe' to: 'C:\ProgramData\Package Cache\{16d7ea68-fda1-4570-a1fc-456ed9f8568d}\Enerprise-Setup.exe'
[2368:101C][2017-06-15T15:00:59]i320: Registering bundle dependency provider: {16d7ea68-fda1-4570-a1fc-456ed9f8568d}, version: 17.3.0.23755
[2368:101C][2017-06-15T15:00:59]i371: Updating session, registration key: SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{16d7ea68-fda1-4570-a1fc-456ed9f8568d}, resume: Active, restart initiated: No, disable resume: No
[2DAC:37F8][2017-06-15T15:00:59]w341: Prompt for source of container: WixAttachedContainer, path: C:\Users\ushanar\AppData\Local\Temp\{4A0621B9-5F9B-4F37-AD2E-721DB8018D46}\.cr\Enerprise-Setup.exe
[2DAC:37F8][2017-06-15T15:00:59]e054: Failed to resolve source for file: C:\Users\ushanar\AppData\Local\Temp\{4A0621B9-5F9B-4F37-AD2E-721DB8018D46}\.cr\Enerprise-Setup.exe, error: 0x80070002.
[2DAC:37F8][2017-06-15T15:00:59]e000: Error 0x80070002: Failed while prompting for source (original path 'C:\Users\ushanar\AppData\Local\Temp\{4A0621B9-5F9B-4F37-AD2E-721DB8018D46}\.cr\Enerprise-Setup.exe').
[2DAC:37F8][2017-06-15T15:00:59]e311: Failed to acquire container: WixAttachedContainer to working path: C:\Users\ushanar\AppData\Local\Temp\{26D6D3E8-B2E7-4ABC-A464-CF3FA97CE905}\A41D8D9647B15BB162A9FFCB9592D53712D43ABC, error: 0x80070002.
[2DAC:37C4][2017-06-15T15:00:59]e000: Error 0x80070002: Failed while caching, aborting execution.
[2368:101C][2017-06-15T15:00:59]i372: Session end, registration key: SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{16d7ea68-fda1-4570-a1fc-456ed9f8568d}, resume: None, restart: None, disable resume: No



-----Original Message-----
From: Harinatha Narisetty 
Sent: Thursday, June 15, 2017 3:03 PM
To: WiX Toolset Users Mailing List <wix-users at lists.wixtoolset.org>
Subject: RE: [wix-users] Right Click run as Administrator VS Programmatically starting as admin.

The vsts host also uses  3.10.3.3007
It runs fine when I right click and run as administrator... All we do inside is  install files and create few windows services.

      <MsiPackage Id='Enerprise'
                  SourceFile='..\Output\en-us\Enerprise-Client.msi'
                  DisplayInternalUI='no'
                  Visible='no'
                  Permanent='no'
                  Compressed='yes'
                  Vital='yes'>
        <MsiProperty Name='PROMOD'                  Value='[PROMOD]' />
        <MsiProperty Name='GENOPS'                  Value='[GENOPS]' />
        <MsiProperty Name='CAPEX'                   Value='[CAPEX]' />
......
.... This is the code we have to embed msi in to bundle..  Does this error say anything ???


[2DAC:37C4][2017-06-15T15:00:55]i300: Apply begin
[2DAC:37C4][2017-06-15T15:00:55]i010: Launching elevated engine process.
[2DAC:37C4][2017-06-15T15:00:55]i011: Launched elevated engine process.
[2DAC:37C4][2017-06-15T15:00:55]i012: Connected to elevated engine.
[2368:101C][2017-06-15T15:00:56]i358: Pausing automatic updates.
[2368:101C][2017-06-15T15:00:56]i359: Paused automatic updates.
[2368:101C][2017-06-15T15:00:56]i360: Creating a system restore point.
[2368:101C][2017-06-15T15:00:56]w363: Could not create system restore point, error: 0x80070422. Continuing...
[2368:101C][2017-06-15T15:00:56]i370: Session begin, registration key: SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{16d7ea68-fda1-4570-a1fc-456ed9f8568d}, options: 0x7, disable resume: No
[2368:101C][2017-06-15T15:00:59]i000: Caching bundle from: 'C:\Users\ushanar\AppData\Local\Temp\{26D6D3E8-B2E7-4ABC-A464-CF3FA97CE905}\.be\Enerprise-Setup.exe' to: 'C:\ProgramData\Package Cache\{16d7ea68-fda1-4570-a1fc-456ed9f8568d}\Enerprise-Setup.exe'
[2368:101C][2017-06-15T15:00:59]i320: Registering bundle dependency provider: {16d7ea68-fda1-4570-a1fc-456ed9f8568d}, version: 17.3.0.23755
[2368:101C][2017-06-15T15:00:59]i371: Updating session, registration key: SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{16d7ea68-fda1-4570-a1fc-456ed9f8568d}, resume: Active, restart initiated: No, disable resume: No
[2DAC:37F8][2017-06-15T15:00:59]w341: Prompt for source of container: WixAttachedContainer, path: C:\Users\ushanar\AppData\Local\Temp\{4A0621B9-5F9B-4F37-AD2E-721DB8018D46}\.cr\Enerprise-Setup.exe
[2DAC:37F8][2017-06-15T15:00:59]e054: Failed to resolve source for file: C:\Users\ushanar\AppData\Local\Temp\{4A0621B9-5F9B-4F37-AD2E-721DB8018D46}\.cr\Enerprise-Setup.exe, error: 0x80070002.
[2DAC:37F8][2017-06-15T15:00:59]e000: Error 0x80070002: Failed while prompting for source (original path 'C:\Users\ushanar\AppData\Local\Temp\{4A0621B9-5F9B-4F37-AD2E-721DB8018D46}\.cr\Enerprise-Setup.exe').
[2DAC:37F8][2017-06-15T15:00:59]e311: Failed to acquire container: WixAttachedContainer to working path: C:\Users\ushanar\AppData\Local\Temp\{26D6D3E8-B2E7-4ABC-A464-CF3FA97CE905}\A41D8D9647B15BB162A9FFCB9592D53712D43ABC, error: 0x80070002.
[2DAC:37C4][2017-06-15T15:00:59]e000: Error 0x80070002: Failed while caching, aborting execution.
[2368:101C][2017-06-15T15:00:59]i372: Session end, registration key: SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{16d7ea68-fda1-4570-a1fc-456ed9f8568d}, resume: None, restart: None, disable resume: No



Thanks
Hari

-----Original Message-----
From: wix-users [mailto:wix-users-bounces at lists.wixtoolset.org] On Behalf Of Hoover, Jacob
Sent: Thursday, June 15, 2017 2:21 PM
To: WiX Toolset Users Mailing List <wix-users at lists.wixtoolset.org>
Subject: Re: [wix-users] Right Click run as Administrator VS Programmatically starting as admin.

For 3.10, that 3rd digit is important.  3.10.3 introduced the clean room for a critical security issue in Windows.  As for the exe size, has your authoring changed at all? Posting the MSI's bundle authoring will let us tell you if it's embedded or not.

If your bundle is requiring admin rights to run, it sounds like you are doing "bad things" inside your bundle. Bundles shouldn't modify machine state, that's what installers are for. 

-----Original Message-----
From: wix-users [mailto:wix-users-bounces at lists.wixtoolset.org] On Behalf Of Harinatha Narisetty
Sent: Thursday, June 15, 2017 12:56 PM
To: WiX Toolset Users Mailing List <wix-users at lists.wixtoolset.org>
Subject: Re: [wix-users] Right Click run as Administrator VS Programmatically starting as admin.

Wix version onpremise is 3.10.3.3007
WIx Version in cloud  is  3.10  not sure about minor version.

Also the exe size produced by onpremise is  265MB  and  cloud one is 115MB. 

I am confused whether the MSI is included  or not... But it works fine when I right click and run as administrator... the only problem is double click...click on elevated button permissions...

Does above information give any clue?


Thanks
Hari

-----Original Message-----
From: wix-users [mailto:wix-users-bounces at lists.wixtoolset.org] On Behalf Of Hoover, Jacob
Sent: Thursday, June 15, 2017 12:50 PM
To: WiX Toolset Users Mailing List <wix-users at lists.wixtoolset.org>
Subject: Re: [wix-users] Right Click run as Administrator VS Programmatically starting as admin.

Why would you have to explicitly elevate?  The engine should do this for you if the Plan determines it needs it.

Is the WiX version identical between your old and new Bundle?

-----Original Message-----
From: wix-users [mailto:wix-users-bounces at lists.wixtoolset.org] On Behalf Of Harinatha Narisetty
Sent: Thursday, June 15, 2017 11:39 AM
To: WiX Toolset Users Mailing List <wix-users at lists.wixtoolset.org>
Subject: [wix-users] Right Click run as Administrator VS Programmatically starting as admin.

Hi friends,
I am facing  weird problem with my WiX Burn.  I have custom boostrapper.  The MSI is included in the Exe. I do have code to request to elevate permissions.
		var myInfo = new ProcessStartInfo
                             {
                                 FileName = Process.GetCurrentProcess().MainModule.FileName,
                                 UseShellExecute = true,
                                 Verb = "runas"
                             };
                Process.Start(myInfo);
                Environment.Exit(0);

We were on on-premise TFS, when the build is done, right click and run as admin OR double click the exe, it would prompt for permissions.. the above code is executed and everything from there is normal.
Now we moved to VSTS, and the build process too.  We have below issue with the executable..
1. Right click and run as admin works fine.
2. Double click, prompts for permission, click on a button to run the code ... basically to launch  as admin... and then  it fails...here is the error message form log file.

[3DCC:3AE0][2017-06-15T12:24:54]i000: Setting InstallationState Applying
[3DCC:3AE0][2017-06-15T12:24:54]i299: Plan complete, result: 0x0
[3DCC:3AE0][2017-06-15T12:24:54]i300: Apply begin
[3DCC:3AE0][2017-06-15T12:24:54]i010: Launching elevated engine process.
[3DCC:3AE0][2017-06-15T12:24:55]i011: Launched elevated engine process.
[3DCC:3AE0][2017-06-15T12:24:55]i012: Connected to elevated engine.
[01EC:3118][2017-06-15T12:24:55]i358: Pausing automatic updates.
[01EC:3118][2017-06-15T12:24:55]i359: Paused automatic updates.
[01EC:3118][2017-06-15T12:24:55]i360: Creating a system restore point.
[01EC:3118][2017-06-15T12:24:55]w363: Could not create system restore point, error: 0x80070422. Continuing...
[01EC:3118][2017-06-15T12:24:55]i370: Session begin, registration key: SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{5d7f183a-77dc-4ddb-9e84-9c901994a7ab}, options: 0x7, disable resume: No
[01EC:3118][2017-06-15T12:25:00]i000: Caching bundle from: 'C:\Users\ushanar\AppData\Local\Temp\{0C5AC74C-B935-4EAC-A95B-B75DBBEDE999}\.be\Enerprise-Setup.exe' to: 'C:\ProgramData\Package Cache\{5d7f183a-77dc-4ddb-9e84-9c901994a7ab}\Enerprise-Setup.exe'
[01EC:3118][2017-06-15T12:25:00]i320: Registering bundle dependency provider: {5d7f183a-77dc-4ddb-9e84-9c901994a7ab}, version: 17.3.0.23744
[01EC:3118][2017-06-15T12:25:00]i371: Updating session, registration key: SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{5d7f183a-77dc-4ddb-9e84-9c901994a7ab}, resume: Active, restart initiated: No, disable resume: No
[3DCC:381C][2017-06-15T12:25:00]w341: Prompt for source of container: WixAttachedContainer, path: C:\Users\ushanar\AppData\Local\Temp\{CF1CC4F5-4945-4E89-B834-7176BE041884}\.cr\Enerprise-Setup.exe

Any idea ???

____________________________________________________________________
WiX Toolset Users Mailing List provided by FireGiant http://www.firegiant.com/

____________________________________________________________________
WiX Toolset Users Mailing List provided by FireGiant http://www.firegiant.com/

____________________________________________________________________
WiX Toolset Users Mailing List provided by FireGiant http://www.firegiant.com/

____________________________________________________________________
WiX Toolset Users Mailing List provided by FireGiant http://www.firegiant.com/

____________________________________________________________________
WiX Toolset Users Mailing List provided by FireGiant http://www.firegiant.com/

____________________________________________________________________
WiX Toolset Users Mailing List provided by FireGiant http://www.firegiant.com/

____________________________________________________________________
WiX Toolset Users Mailing List provided by FireGiant http://www.firegiant.com/

____________________________________________________________________
WiX Toolset Users Mailing List provided by FireGiant http://www.firegiant.com/

____________________________________________________________________
WiX Toolset Users Mailing List provided by FireGiant http://www.firegiant.com/

____________________________________________________________________
WiX Toolset Users Mailing List provided by FireGiant http://www.firegiant.com/



More information about the wix-users mailing list