I created a simple bootstrapper for my application using WixSharp.
namespace TestBootstrapper
{
class Program
{
static void Main()
{
var package = new MsiPackage("../testmsi.msi")
{
DisplayInternalUI = true,
Id = "MyId",
Compressed = true,
Visible = true
};
var bootstrapper = new Bundle("MyTestInstaller", package)
{
Version = new Version("1.0.0.0"),
UpgradeCode = new Guid("1FCC927B-7BB0-4FB0-B81E-2D87012E470B"),
PreserveTempFiles = true,
DisableModify = "yes",
DisableRemove = true
};
bootstrapper.Build("Installer.exe");
}
}
}
I logged as admin and installed the application (using Installer.exe) and there were no errors in Event Viewer during installation. When I clicked shortcut the application runs as expected.
If I run testmsi.msi as standard user or admin it installed without any errors and if I clicked shortcut the application runs as expected.
I logged as standard user and installed the application (using Installer.exe). There were no errors in Event Viewer during installation. But when I clicked shortcut installer runs again.
So, why installer runs and how to prevent this behavior?
It's a repair, which may be good or bad depending on what is being re-installed. The application event log should have MsiInstaller entries that say something about what is being repaired. It's not necessarily a bad thing that needs to be prevented.
Assuming you did a per-machine install, if you installed (for example) a file into the User's Application Data folder from your MSI, and then you log on as another user and run the app, then the file is obviously missing for that user. So Windows Installer will do an install for that missing part of the app. The file is probably required for all users of the system, yes? Windows assumes that if you install a file (or registry entry) into a user profile location then everyone that logs on needs this file, so it gets installed by "repair" when another user logs on and uses the shortcut.
There are other scenarios where a repair is not so good. If you do something to remove a file that you installed then Windows will attempt to restore it. If you do a per-user install but then log on as another user and try to use the app that's not an intended use of the product - installer per machine to do that.
I just discovered something that might help -
If you are not installing any programs to the Application directory (for example only installing to Local App data), Windows Installer generates an error message because the Application directory doesn't exist.
If you add ANY file to the Application directory, or create it manually, the shortcut will work properly.
Related
We have an application which shows up as an Excel ribbon.
We have installed the application in our test environment through administrator login. We are trying to make a per machine installation.(Please note that in production environment, the installation will be through system account).
When we login as user to the same PC, we don't see the excel addin in the Excel ribbons. We don't see the addins anywhere in the list of addins as well.
We have tried using Active setup,Userstat,setting the values of properties as ALLUSERS=1, RegisterForAllUsers= True, InstallScope= perMachine, InstallAllUsers = Everyone, RunActionsAsInvoker = True . Also the privileges has been changed from user to admin in all the cutom actions and in manifest file as well. All these changes where made as we understood that the application used to package is Addin express and so the msi creation with privileges as admin is possible.
Unfortunately none of these changes seems to help us.
What we would need is an msi which we can install on per machine basis.
From the situation mentioned in the question, we had tried a lot of options and finally following approach works for us:-
Create a package which would place a powershell shortcut in the startup folder.
The shortcut would in turn call or execute a powershell script.
The powershell script would
1. check if the registry key for that particular add-in is available in HKCU.
We had our registry key as "HKCU\Software\Manufacturer Name\Product Name" which in turn had a string value "Installed".
If the registry key is not available for the user, then install the package with tranform.
3.If the registry is already available, then script doesn't make any change.
The package is installed as an Admin and once the user logs in, then automatically the cmd file is executed and the add-in is installed.
Since this was the first version of the product, we didn't have to handle version compatibility.
I have a program that auto-updates itself when it finds a newer version MSI. I used to create the MSI with a VS2008 Setup project. I migrated the development to VS2013, lost the Setup project, tried IS and got extremely frustrated and finally landed with WIX.
The MSI created with WIX does all I need but fails in the auto-update logic:
Because the program can be running under a limited user account, when it detects a newer MSI, it first Advertises it with the credentials of an Administrator. These credentials are stored encrypted in an XML file.
Then, once the MSI has been advertised, it is launched with the current user. The code (in short)
Process^ advertise = this->advertiseMSI(shortpath,mydomain,myusername,mypassword);
advertise->WaitForExit();
Process^ install = this->installMSI(shortpath);
Where advertiseMSI is:
Process^ process = gcnew Process();
process->StartInfo->UseShellExecute = false;
process->StartInfo->FileName = "C:\\Windows\\System32\\msiexec.exe";
process->StartInfo->Arguments = "/jm " + "\"" + msiPath + "\"";
process->StartInfo->WorkingDirectory = Environment::GetEnvironmentVariable("WINDIR");
process->StartInfo->UserName = userName;
process->StartInfo->Password = this->getSecureString(Password);
process->StartInfo->Domain = userDomain;
process->StartInfo->Verb = "runas";
process->Start();
return process;
and installMSI just launches the Msiexec in a silent install with the current user.
This worked fine with the MSI created with VS2008 but it fails with the WIX MSI.
The log of the msiexec is:
"Error 1730. You must be an Administrator to remove this application..."
If I run the MSI manually, it works when logged as admin but when logged as user it fails and doesn't ask for elevating privileges.
I have set InstallPrivileges="elevated" InstallScope="perMachine" in the Package section and does not make a difference (I have tried every possible combination of those). It seems to me that the MSI is not advertised but the code does not fail. Looks like the MSI is always run with limited privileges.
I have also tried to set AllowAdvertise="yes" in the only one Feature of the product.
One main difference I can see with the MSI produced with VS2008 is that the later had two features, Admin and user.
I don't know if you're still struggling with this problem, but I've come across a similar problem with an installer built with NSIS, so perhaps this will help you or others. I was able to overcome this in my situation by using command shell indirection as follows (C# code):
ProcessStartInfo processInfo = new ProcessStartInfo("cmd", "/C myapp_installer.exe /S /D"); // Options /S /D apply to myapp_installer.exe.
processInfo.UseShellExecute = false;
processInfo.Domain = domain;
processInfo.UserName = username;
processInfo.Password = password; // Obtain securely not hard-coded.
Process process = Process.Start(processInfo);
I can't fully explain why this works, when directly calling the installer fails to pass the required credentials, but I'm pretty certain that it has to do with what is explained by Chris Jackson on the MSDN Blog, which incidentally was referenced in the answer to your related question.
I hope this helps!
I have developed a e4 RCP aplication.
While launching the application, creating a folder "workspace" and inside that /.metadata/.lock
So when i switch user, i am getting a error that already one user is using/locked your application and can't run.
Error: C:\Program Files.....\workspace.metadata.lock(Access denied)
But i need to run my application to multiple user support in XP
I have this issue only in XP. in vista,windows7 and windows 8 working fine
Any help or workaround to run the the application after the user switch(which is running in other user)?
Update
I have done this by adding below line in my product file, which will take care of launching the application in user workspace
<launcherArgs>
<programArgsWin>-data #user.home/workspace</programArgsWin>
</launcherArgs>
Not sure if this works on XP but you could try setting the workspace to be in the user's home directory. You can do this in the 'LifeCycle' '#PostContextCreate' method:
#PostContextCreate
public void postContextCreate()
{
final Location instanceLoc = Platform.getInstanceLocation();
// TODO instanceLoc will be null if user specifies -data #none option
// TODO instanceLoc.isSet() will be true if user specifies -data path
// Set the default
final Path path = Paths.get(System.getProperty("user.home"), "workspace name");
instanceLoc.set(path.toUri().toURL(), false);
I have a strange problem using vb.net (vs2010) and SQLite database: I made an install package with Setup and Deployment project, everything seems to be working fine. My SQLite databse installs under CommonApplicationData folder and the software under ProgramFiles\ProductName. In the setup project I set a custom action, the user have a choice to run software after install:
/StartApp="[CHECK]"
Private Sub MyInstaller_Committed(ByVal sender As Object, ByVal e As InstallEventArgs)
Dim productName As String = Context.Parameters("ProductName")
StartAfterInstall = Me.Context.Parameters.Item("StartApp")
If StartAfterInstall = "1" Then
Directory.SetCurrentDirectory(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location))
Shell(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + "\FB.exe")
End If
End Sub
In ApplicationEvents.vb I set at StartUp:
AppDomain.CurrentDomain.SetData("DataDirectory", Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData))
And here comes the strange behaviour: if the user starts application after install, the program connects to another(?) database, not to installed under CommonApplicationData. If the user inserts data, seems everything working fine.
After closing the application and starting new from the desktop/programfiles/users program menu connects the program to the database installed under CommonApplicationData, but he can't see the changes he made launching application after installation. So starting program from desktop/programfiles/users program menu => everything fine, but the first (automatic) start after install is a problem. I can't find out what happens, any ideas?
Has your Installation Administrator-Privileges?
If yes, the following probably happens:
you are writing to ProgramFiles. Windows redirects this to the administrator %appdata%\roaming folder because writing to ProgramFiles is considered bad.
It goes to the administrator account because the installation had administrator-privileges.
When you start your program from the user account, the user-specific %appdata% Folder is used, which is empty.
Do solve that problem:
do not launch your program from the installer.
Create a directory for your program in %appdata% and usw it.
I'm using c#, .net 4, WIX 3.5, Windows Vista.
I have made my application compatible with RestartManager by p/invoking the RegisterApplicationRestart method and by handling the WM_QUERYENDSESSION and WM_ENDSESSION window messages (I return new IntPtr(1);).
If I try to update my application manually, then everything works as it should:
Launch application;
Launch msi file containing new app version;
During the installation/update, I'm prompted to close the running application;
Upon continuing the running app is closed, install completes, and the app is restarted;
If I try to update my application from the application itself, then I run into problems:
1) Launch application;
2) Download the new msi file;
3) Launch msi file with:
using (System.Diagnostics.Process p = new System.Diagnostics.Process())
{
p.StartInfo.UseShellExecute = false;
p.StartInfo.FileName = "msiexec";
p.StartInfo.Arguments = "/i \"" + downloadPath + "\" /passive";
p.StartInfo.UserName = "Administrator";
p.StartInfo.Password = securePassword;
p.Start();
}
4) Because I'm using passive mode, the application is closed automatically;
5) After the installation, my application is not restarted and under Event Viewer I have an
Event 10007 - Application or service 'MyApp' could not be restarted.
I have tried:
Not to use passive mode for msiexec;
Launch msiexec via cmd.exe (cmd.exe /C "msiexec /i ....") - in the hopes that launching msiexec from another process would solve the problem;
Wait for 60+ seconds before launching the msi update (shouldn't be relevant in my scenario, but MSDN documentation has something about it...)
But none of the above has worked (always the same result).
Having to launch the setup with elevated permissions might have something to do with the issue, because during the manual update I get a warning in the Event Viewer - Application MyApp (pid 3220) cannot be restarted - Application SID does not match Conductor SID.
Despite this, restarting the app still works. Googleing the warning yields no good/specific results, only that this warning is probably caused by running the msi in an elevated prompt.
How do I fix (or workaround) this issue, so that I can update my application from the application itself and restart my application afterwards?
Edit - extra testing:
There doesn't seem to be a need to respond to WM_QUERYENDSESSION and WM_ENDSESSION messages, because application restart during a manual upgrade works without them, so we can rule them out;
If I don't provide administrator credentials to the application initiated upgrade and instead I type them in during the upgrade, then app restarting works;
If I run an elevated command prompt and initiate an application upgrade from there (manually), then app restarting still works;
In order for application upgrade to work at all under Standard user accounts (so far I tested under an Administrator account with UAC), then I also have to set p.StartInfo.LoadUserProfile = true;. Otherwise nothing happens. (application restart still doesn't work though);
I tried all other process StartInfo parameters that I could set - WorkingDirectory, Redirect, Verb
(= "runas") - no change in results;
I installed Vista SP2 onto the virtual machine that I have been testing on (so far ran SP1), but no change;
I performed an "automatic" application upgrade with verbose logging. In the end there was an error message - RESTART MANAGER: Failed while restarting applications. Error: 352. That error code is very generic (http://msdn.microsoft.com/cs-cz/library/aa373665), inorder to get more detailed info I would have to write my own installer that would call RmGetList after the error, then I might get more details (this though is something I'm not willing to do);
Edit 2 - msi log file:
http://mommi.planet.ee/muu/log.txt
Assuming that the manual process indeed works without any problem it seems that your need for Administrator privileges in combination with the "updating itself" leads to these problems. I see the following options:
create a batch file to execute the update
When you want to update call this batch file (with elevated privileges), make the app close itself... the batch file should wait some seconds, then check whether the app is still running (and close it in case) and then run the commandline you need to run msiexec - don't restart the app from within msiexec but after a successfull run of msiexec from the batch file.
create a batch file which is always used to start the app
When the time comes to update you just end the app. Either the batch file check for an available update and applies it, starting the app after successfull update OR the app set some environment variable which is then accordingly processed by the rest of the batch file.