How to Prevent an Application from Being Uninstalled

how to prevent application to be uninstalled by a user (w/o admin rights)?

[updated]
the file location is easy. That is simple revoking write permission on the folder and all its subfolders and files for Builtin\Users, and giving Builtin\Administrators full permmision. You can set this via the Explorer, properties-> permissions or commandline wise with cacls (or icalcs if you're on win7)

The regkey is on my win7 box already only readable (not writeable) by Users and read/write by local admins (regedit -> Context menu -> Persmissions).

If it still doesn't behave like you want figure out what groups a normal user is in (also domain groups) and then check how those groups are propagated to the local machine.

And as sugested by Ben in the comments, you might start a new question on Server Fault.

[end update]

[before edite response]
I doubt you can disallow the uninstall of 'one' application. By means of a Group Policy you can "Pohibit removal of updates"

(in GPedit.msc under Computer Config/Admin templates/windows components/windows installer)

The Group Policy is set by a domain admin and is enforced across the domain so it doesn't require 'persmissions'. But you need off course to also prevent local admins from editing the local group policy.

Another more daunting option would be to use a group policy in the Software Rectriction part of Security Settings. Here you can enter a path policy for the name of the msi or exe file that you do not want to be run.

Both require validating/testing to prevent that to much restriction prevent everybody from starting anything...

Prevent app from Uninstall in Android

This is not possible. You cannot decide on your own to make your app be a device administrator. You are welcome to lead the user over to the appropriate spot in the Settings app to have the user elect to make your app be a device administrator, though, via ACTION_ADD_DEVICE_ADMIN.

For example, this activity will see if it is already a device admin (via isActiveAdmin()), then will launch an ACTION_ADD_DEVICE_ADMIN activity if needed:

/***
Copyright (c) 2012 CommonsWare, LLC
Licensed under the Apache License, Version 2.0 (the "License"); you may not
use this file except in compliance with the License. You may obtain a copy
of the License at http://www.apache.org/licenses/LICENSE-2.0. Unless required
by applicable law or agreed to in writing, software distributed under the
License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
OF ANY KIND, either express or implied. See the License for the specific
language governing permissions and limitations under the License.

From _The Busy Coder's Guide to Android Development_
http://commonsware.com/Android
*/

package com.commonsware.android.lockme;

import android.app.Activity;
import android.app.admin.DevicePolicyManager;
import android.content.ComponentName;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;

public class LockMeNowActivity extends Activity {
private DevicePolicyManager mgr=null;
private ComponentName cn=null;

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

setContentView(R.layout.main);
cn=new ComponentName(this, AdminReceiver.class);
mgr=(DevicePolicyManager)getSystemService(DEVICE_POLICY_SERVICE);
}

public void lockMeNow(View v) {
if (mgr.isAdminActive(cn)) {
mgr.lockNow();
}
else {
Intent intent=
new Intent(DevicePolicyManager.ACTION_ADD_DEVICE_ADMIN);
intent.putExtra(DevicePolicyManager.EXTRA_DEVICE_ADMIN, cn);
intent.putExtra(DevicePolicyManager.EXTRA_ADD_EXPLANATION,
getString(R.string.device_admin_explanation));
startActivity(intent);
}
}
}

(from this sample project)

The two extras (EXTRA_DEVICE_ADMIN and EXTRA_ADD_EXPLANATION) are optional, though they are a good idea. The first one should be a ComponentName identifying your DeviceAdminReceiver subclass; the second one should be a string (from a string resource) that explains why the user should make your app be a device admin.

My app is about security and needs to be protected from getting uninstalled.

Since anybody can go in and decide to not make your app be a device administrator (again, through Settings), then uninstall it, this is not much of a defense.

How to prevent an application from being uninstalled?

Ankur,

I think the closest thing to what your looking for is the Device Administration feature introduced in 2.2.

Once the application is registered as a Device Administrator, it can't be uninstalled unless its unregistered. This will prevent the app from being uninstalled.

While the Device Admin API doesn't allow for password protection of this particular feature, you can password protect your application to prevent someone from tampering with the Device Admin features in the app.

I use an app called SeekDroid that has a similar functionality.

How do I prevent my application to being uninstalled on Android

Android is a OS just like windows, linux and Mac. The OS has features that it allows/disallows its applications from using. You will need to probably write a native app on jail broken phones to get that kind of control on the OS.

How do I prompt a user for password when uninstalling an application or make the app uninstallable?

This works from me. Application not showing in the control panel. Thank you Siyabonga Gregory
RegistryKey key = null; key = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\{63EF3DE1-F37C-4B1B-BBBD-26910690C7CF}", true); key.DeleteValue("ModifyPath", true); key.DeleteValue("UnInstallString", true); key.DeleteValue("Version", true); key.DeleteValue("VersionMajor", true); key.DeleteValue("VersionMinor", true); key.DeleteValue("WindowsInstaller", true); key.Close();

How do i prevent my app from uninstalling?

Please refer Device Administrator

Once the application is registered as a Device Administrator, it can't be uninstalled unless its unregistered. This will prevent the app from being uninstalled.

For example this application is using same functionality.

Make sure if you install above application(SeekDroid) you must sign up then it will ask for device admin permission. :)



Related Topics



Leave a reply



Submit