Install4j duplicate shortcut on desktop - install4j

When installing an application (packed with install4j) onto a computer that already
has it installed with admin and then with other user rights,
the installer will produce another icon on the desktop
resulting in 2 or more application icons.
To reproduce this:
Install the application as an admin user on windows
Log into another user account that is not an admin.
(A normal user account)
Install application once again, and after the client is finished installing it will produce another icon on the desktop
How can I avoid this behavior?

There are two different desktop folders involved, the public one and the user specific one. If the "Create for all users" property of the "Add a desktop link" action is selected, the action will try to create the link in the public folder, but that usually requires admin privileges. If you don't have admin privileges, you could check if such a file already exists in the public folder. The condition expression of the action could be set to something like:
if (!Util.hasFullAdminRights()) {
File publicLink = new File(WinFileSystem.getSpecialFolder(
SpecialFolder.DESKTOP, true), "launcher name.lnk");
return !publicLink.exists();
} else {
return true;
}

Related

Parsing a restricted Word file

I am working on a Windows standalone application. [ I can not disclose the name as per our company policy]
I installed Azure Information Protection Client.
Then I protected the Word file with the below steps:
Go to File ribbon > Info tab
"Protect Document" button > Restrict Access > Restricted Access
Check "Restrict permission to this document" > OK
Save the document > Exit the application
Now my Application tries to parse this restricted file with the below steps.
Unzip the Word file
Read the OOXML content and extract needed information
Create an output file with this extracted information
but the application cannot unzip the word file because it is restricted.
So my question is do we have any Microsoft API to unzip the restricted file?
is there any other way to read OOXML data from such a restricted file?
by including MIP SDK (https://learn.microsoft.com/it-it/information-protection/develop/) in your application, you can use this function:
public void GetDecryptedTemporaryFileAsync(const std::shared_ptr< void>& context)
to get a decrypted temporary version of the protected file, so that the rest of your application goes on as normal.
MIP SDK should be configured to run with an account that is allowed to access the protected file, or run as "superuser", so that the process can access any protected file.
Evaluate carefully the protection scenario before using the superyuser feature.

Install4j is not able to detect the previous installations with another user by getApplicationInfoById() if installed on other than program files path

Install4j is not able to detect the previous installations with another user by getApplicationInfoById.
I am installing app1.0.0 in C:\appdir\ with an admin account or user1.
Then I am trying to install the same app1.0.0 in C:\Program files\appdir with an administrator account or user2. So before that, I am checking if the same application is already installed? using the app id.
the expected result is it should not install again in a new folder and give msg the application is already installed. but getApplicationInfoById is not able to find the previous installation.
findings:
If the application is already installed in program files then-new app is able to detect by getApplicationInfoById in different users as well.
If the application is already installed other than program files then-new app is able to detect by getApplicationInfoByDir in different users as well.
If the application is already installed other than program files then-new app is not able to detect by getApplicationInfoById in different users as well.
Note: App id is the same for previous and new apps.
Note: Install4j 8.0.8 version used
// Check if the user has already installed the application
ApplicationRegistry.ApplicationInfo applicationInfo =
ApplicationRegistry.getApplicationInfoByDir(context.getInstallationDirectory());
if (applicationInfo == null) {
Util.logInfo(null, "prev installation not found in current installtion dir");
Util.logInfo(null, context.getApplicationId().toString());
// if installation not found same path then check everywhere using app Id
ApplicationRegistry.ApplicationInfo[] applicationInfos =
ApplicationRegistry.getApplicationInfoById(context.getApplicationId());
for (int i = 0; i < applicationInfos.length; i++) {
Util.logInfo(null, "prev installation detected with diff path ");
if (i == 1){
Util.logInfo(null, "multiple installtion detected");
}
context.setInstallationDirectory(applicationInfos[i].getInstallationDirectory());
applicationInfo = applicationInfos[i];
}
// The application has never been installed before
if (applicationInfo == null){
return true;
}
}
It is not important if the installation directory is inside the program files directory or not. What makes the difference is if the "Request privileges" action has been executed. Only then can the installer save the previous installation directory in a public part of the registry. Otherwise, a user-specific part of the registry must be used that is not readable by other users.

Using Lucee Server with Command Box problems accessing Server Administration page

I recently downloaded CommandBox to try to set up a Lucee Server. I have a folder called LuceeSever with an Index.cfm page. When I type the command "box server start" it opens a window at this address: http://127.0.0.1:54613 displaying my index.cfm page. Cool.
But I would like to connect a datasource and I would like to do this thorough the server admin panel that everyone else says to use. So when I try to access http://127.0.0.1:54613/lucee/admin/server.cfm I get this screen:
So I created a password.txt file that contains 1 line of plaintext that is the password I wanted to use. So my directory looks like this:
LuceeServer>
index.cfm
password.txt
In which index.cfm and password.txt are at the same level. When I click import file the screen reloads and nothing happens.
I assume I have things set up incorrectly. I've never used commandbox before and I dont really know what I'm doing.
You can bypass this entirely by using CFConfig. You can either specify the adminPassword in your .cfconfig.json file
{
"adminPassword":"myPass"
}
or you can install commandbox-dotenv and set a global .env file that has a cfconfig_adminPassword key.
~/.box.env
# Add environment variables to be loaded into CommandBox when it starts
# Variables are in the form of foo=bar, one per line
cfconfig_adminPassword=myPass
Disclaimer: I am the lead developer of CommandBox and the CFConfig module.
When you run your server with CommandBox, click on its tray icon in the right corner of your desktop, click open and then the server home folder like shown on the image below:
Then navigate to /WEB-INF/lucee-server/context/ and place your password.txt file there. Then go back to lucees server admin page in your browser and click the "import file" button to import the password.txt file.
Your password.txt needs to go in the "root Lucee server directory", which isn't the same as your site's web root (which wouldn't be a very secure place to put it). In CommandBox the location is a bit obscure, but you can find it with the following command:
server info property=serverHomeDirectory

Service is not running when OS is upgraded from Windows 8.1 to Windows 10

We have upgraded windows from 8.1 to 10.
Now in Windows 10 services installed by us are not running.
The same services are running properly if we install these services on Windows 8.1.
ON windows 10, we tried below things which didn't solve the problem.
services-> select service -> properties -> Set [Log on] as LOCAL SERVICE
Set full permission to "perticuler" user or "everyone" user for the folder where service files exist.
Change owner of folder as "everyone", "system" or "perticuler" user where service files exist.
Below is a workaround which works but not feasible for us since it requires password and actually we want to know the actual reason behind this problem.
workaround :
1. services-> select service -> properties -> Set [Log on] as "This account" where user can be selected and it also requires password. Refer attached image.
Please note that the service is a dot net(c#) service and it runs internally a jar file. if it is able to run jar file then only service starts successfully.
Thanks in advance
I have found the cause and solution.
[Cause of problem]
Service unable to understand that, to run JAR file, which program should be run.
[Detail]
I tried to debug the code.
At the location where process is started, popup message like shown in below image is occurred.
location : processSample.Start()
It means that atleast once user need to select the program.
If we select [Java(TM) Platform SE binary] once, then after that the
service always runs successfully.
This behavior is in Windows 10 only.
In addition to program selection, user setting shown in image in question is also required to run the service.
I want to say that, in default program setting already correct program is selected for .jar files as shown in below image, but still windows 10 asks user to select program once.
[Solution]
Run JAR file from windows(c#) service with settings below :
sampleProcess.StartInfo.FileName = "javaw.exe";
sampleProcess.StartInfo.Arguments = "-jar Sample.jar";
sampleProcess.StartInfo.WorkingDirectory = #"C:\SampleFolder";
sampleProcess.StartInfo.UseShellExecute = false;
sampleProcess.EnableRaisingEvents = true;
sampleProcess.StartInfo.CreateNoWindow = false;
Here working directory is the location where the [Sample.jar] does exist.
additinally a Path environment variable must be set in order to execure "javaw.exe".
Before fix I had implementation as below which is not proper for every system environment :
sampleProcess.StartInfo.FileName = "Sample.jar";
sampleProcess.StartInfo.WorkingDirectory = #"C:\SampleFolder";
sampleProcess.EnableRaisingEvents = true;
sampleProcess.StartInfo.CreateNoWindow = false;

Object contains only the public half of a key pair

Upon installation of a client side certificate, I am getting the exception "Object contains only the public half of a key pair. A private key must also be provided". My application is a VC#.NET application running over an ASP.NET platform. The application also uses WSE 2.0 to import certificates into making SOAP requests.
Upon research, I've found that this exception is of type System.Security.Cryptography.CryptographicException.
I am pretty positive all my WSE settings are configured correctly, since I was able to find a similar certificate by subject-distinguished-name. Any ideas will be greatly appreciated.
I was recently having the same problem. I found one explanation here that worked for me. Specifically, the permissions for the private key. The full info is copied below.
There are a couple things that I would
look at first:
Do you have a private key for this certificate?
Have you given permission for youf application to access the private
key?
You can establish whether you have a
private key by viewing the certificate
through the Windows Certificate Store.
To get to this, follow these steps:
From the Windows Start menu, select Run.
Type mmc in the Open: field. Click OK
Select "Add/Remove Snap-in" from the File menu.
Click the Add button.
Select "Certificates" from the list of Available Standalone Snap-ins.
Click the Add button.
Select "Computer account." Click Next.
Select "Local Computer". Click Finish.
Click Close.
Click OK.
Expand the Certificates node under the Console Root and open the
Personal store.
Double-click the Certificate you're using. If you have a private
key, the dialog will display a message
at the bottom that says "You have a
private key that corresponds to this
certificate".
If you have a private key, then ensure
that your application has permission
to access the key:
Open Windows Explorer.
Navigate to the C:\Documents and Settings\All Users\Application
Data\Microsoft\Crypto\RSA\MachineKeys
folder.
Select the files containing the keys that the WSE will need to
retrieve.
From the File menu, select Properties.
On the Security tab, add the ASPNET account and select th e Full
Control option.
Notes:
1. Determining which key file in the MachineKeys folder is
associated with a certificate can be
difficult. One easy method is to note
the creation date and time when
creating a new certificate. When you
view the files in the MachineKeys
directory, check the Date Modified
field for the corresponding date and
time.
2. If you have configured your system to run under a different
account than ASPNET, use that account
when granting permissions to access
the certificate.
As per my experience it could be failing because of two reasons.
Check if your cert has private key available.
If that is .net application then check if you have given permission to cert to make sure your application has permission to access the cert. In my case adding the "iis_iusrs" and given read permission does work for me.
Thanks.
After encountering the same exception: System.Security.Cryptography.CryptographicException, Object contains only the public half of a key pair, I proofed an alternative, but less optimal solution.
Situation: Certificate / key look up worked great inside of Visual Studio IIS Express, but while the Web Application was running under the proper IIS service, I always received the 'Contains only public half of key pair' exception.
I used the WSE3 CertificateTool to locate the private key section on the filesystem and attempted at length to adjust the user permission settings to give the ASP user permissions as per the above answer.
My eventual fix, which was not pretty, was to create a new IIS Application Pool specific to my Web service code and set the user Identity the pool runs as the Local machine owner of the certificate + private key.
The final location I installed the certificate in was "Local Computer / Trusted People".
Using WSE3 CustomPolicyAssertion, C# .NET:
clientToken = X509TokenProvider.CreateToken(StoreLocation.LocalMachine,
StoreName.TrustedPeople, "soap.partnersite.com", X509FindType.FindBySubjectName);
After updating the App Pool Identity, no private key file overrides were necessary when changing the application pool owner.