why e4 rcp application is locked in windows XP and not launching for other users in same machine - locking

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);

Related

Why installer runs after click on shortcut?

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.

Encountering "the system cannot find the file specified" when running a certain command

This is a problem I have never seen before. Whenever I run a certain command in my application, I am getting the error:
Could not load file or assembly 'CADB.Data'. The system could not find the file specified.
When I run the command in the debugger, I do not get this error. The system completes the process successfully. It is only when I am running the built .exe. The .exe is in my debug folder with all of the necessary DLLs (Copy Local = True) including the problem DLL (CADB.Data).
When the system runs this command, it is under impersonation. I put the Debug folder (containing .exe and DLLs) into a folder the impersonated user has full access to. I checked access in the Security tab of file properties, and the user has full access to the folder AND CADB.Data.dll. Still, I get the error message above. When I run the program through any other folder that the impersonated user does not have access to, I get a slightly different error: Could not load file or assembly 'CADB.Data'. Access is denied.
Running the application through the debugger on another workstation throws the error as well. The error occurs at the declaration of the method GetClaimGuidList which is a member of CADB.Data (below).
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using CADB.Data;
namespace CADB.BusinessServices
{
public class ClaimHelper
{
static public List<Entities.Claim> GetClaimGuidList(int caseId, bool includeNotices)
{
DataTable dt = ClaimCmd.GetClaimGuids(caseId, includeNotices);
return Utilities.MapDataTableToList<Entities.Claim>(dt);
}
}
}
Other things tried:
Setting DLL as read/write. It was read-only because the file was originally being edited by VSO and thus had a read-only mark.
Running process monitor to look for an access denied message. I don't find such a message anywhere in the monitor.
Removing the DLL and adding it again from the project (my solution has multiple projects).
Cleaning the entire solution, re-building and re-running the EXE
Deleting the bin folder of every project in the solution, re-building and re-trying
Can anyone help? Any ideas would be greatly appreciated. Thanks.
For some reason, the impersonated user did not have access to the application files created in the bin folder. I went to the Security properties of the folder and added that user to the folder with full access rights. This allowed us to bypass the error. Why the user was not able to access the CADB.Data DLL is still a mystery. In any case, the issue was not present in the published ClickOnce application.

"Access to this path is denied" in Windows 7 application

Ran into a strange phenomena:
in Application A, the code:
Using sr = New StreamReader(path)
runs perfectly (where path is C:\tmp for example. The directory is on the local machine).
In Application B the same line, on the same directory throws the exception: "Access to the path is denied".
This happens when run in the IDE or by activating the exe file.
Some additional information:
Windows 7 Pro, 64bit VS 2013
The app.manifest of both application is identical. I've tried changing to all possible options of requestedExecutionLevel but the result was the same.
The target framework of the application is 4.
The exception is thrown whether I run as administrator or not.
I've set the permissions of the directory to full control for all accounts (including Administrator and Everyone).
I've deleted the directory and recreated it. Didn't help.
Ran Farbar scan which did not report any problems.
Application A is referencing the FILE C:\tmp. I expect this file isnt present on Application B's machine.
http://msdn.microsoft.com/en-us/library/vstudio/f2ke0fzy
Also ensure you are properly disposing of your StreamReader class after use. if you dont do this the file can remain locked.

Program connects after install to an unknown(?) sqlite database

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.

RestartManager fails to restart application during update

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.