Skip to content
Home » Android » Fix “Exception Occurred while Executing Command” on Samsung

Fix “Exception Occurred while Executing Command” on Samsung

The Security Folder on Samsung phones acts as a virtual vault that shields personal information from unauthorized access. This folder stores your financial records, private media files, or important documents files securely. However, if you enable Secure Folder or Auto Blocker on your Samsung device, you may encounter the “exception occurred while executing” error while executing ADB Shell commands. This tutorial will provide workarounds to fix this error on Samsung Galaxy devices.

What is ‘User 150’ on Samsung Devices?

One day, I needed to get a list of the system apps installed on my Galaxy S24 but when I executed the command, I got the following error in PowerShell.

e3q:/ $ pm list packages -s

Exception occurred while executing 'list':
java.lang.SecurityException: Shell does not have permission to access user 150
com.android.server.am.ActivityManagerService.handleIncomingUser:15889 android.app.ActivityManager.handleIncomingUser:5134 com.android.server.pm.PackageManagerShellCommand.translateUserId:3733
at com.android.server.am.UserController.handleIncomingUser(UserController.java:2892)
at com.android.server.am.ActivityManagerService.handleIncomingUser(ActivityManagerService.java:15889)
at android.app.ActivityManager.handleIncomingUser(ActivityManager.java:5134)
at com.android.server.pm.PackageManagerShellCommand.translateUserId(PackageManagerShellCommand.java:3733)
at com.android.server.pm.PackageManagerShellCommand.runListPackages(PackageManagerShellCommand.java:1074)
at com.android.server.pm.PackageManagerShellCommand.runListPackages(PackageManagerShellCommand.java:960)
at com.android.server.pm.PackageManagerShellCommand.runList(PackageManagerShellCommand.java:800)
at com.android.server.pm.PackageManagerShellCommand.onCommand(PackageManagerShellCommand.java:237)
at com.android.modules.utils.BasicShellCommandHandler.exec(BasicShellCommandHandler.java:97)
at android.os.ShellCommand.exec(ShellCommand.java:38)
at com.android.server.pm.PackageManagerService$IPackageManagerImpl.onShellCommand(PackageManagerService.java:7112)
at android.os.Binder.shellCommand(Binder.java:1104)
at android.os.Binder.onTransact(Binder.java:914)
at android.content.pm.IPackageManager$Stub.onTransact(IPackageManager.java:4905)
at com.android.server.pm.PackageManagerService$IPackageManagerImpl.onTransact(PackageManagerService.java:7096)
at android.os.Binder.execTransactInternal(Binder.java:1380)
at android.os.Binder.execTransact(Binder.java:1311)

Error: Exception occurred while executing 'list':

If the Samsung Secure Folder is enabled, you’ll get the following error when running the ADB uninstall command.

Exception occurred while executing 'uninstall': 
java.lang.SecurityException: Shell does not have permission to access user 150

All the “exception occurred while executing” errors say that the ADB “Shell does not have permission to access user 150”. ‘User 150’ on Samsung Galaxy devices refers to a specific user profile that is activated when the Secure Folder is enabled. Since ADB Shell commands can perform advanced tasks like pushing and pulling data, any attempt to execute such commands is blocked by the Samsung device. Moreover, when the ‘user 150’ is active, ADB treats your Samsung device to have multiple user profiles and it fails to perform tasks because the user ID is not mentioned in the command.

Suppose, you have multiple Android devices connected to your computer. If you issue a plain ADB command without mentioning the device ID, the command won’t work because ADB requires directions as to which device you want to send the command to. Below is a screenshot of the device IDs listed under ADB devices.multiple android devices connected to adb

In such a case, you must specify ID of the device 1 or device 2 in your command as shown below.

adb -s RZCX11NEPKK shell

If you are trying to execute ADB commands wirelessly via ADB over Wi-Fi, you have to specify the IP address and port as the device ID of the target Android device.

adb -s 192.168.1.6:5555 shell

The simplest way to save yourself from mentioning the device ID in ADB commands is to disconnect one of the devices.

In the same way, if only one Android device is connected to ADB but there are multiple user profiles on the device, you must specify the user ID in your ADB command to make it work. By default, the user ID of the device owner on Android devices is ‘user 0’. If you have created another user, the ID for the second user will use ‘user 1’. Similarly, the user ID of the Samsung Secure Folder is ‘user 150’.

Fixing “Exception Occurred while Executing Command” Error on Samsung

Now that you know how to deal with ADB commands when multiple devices are connected to your computer or multiple user profiles are present on your Android device, you can try the workarounds provided below.

Uninstall the Samsung Secure Folder

Since the root cause behind the “Shell does not have permission to access user 150” error is the Samsung Secure Folder, you can uninstall it to get rid of the issue.

  1. Go to Settings > Security and Privacy on your Samsung device.security and privacy settings android
  2. Tap on More Security Settings.security and privacy settings on samsung
  3. On the next screen, select  Security Folder.more security settings on samsung galaxy phone
  4. On the Security Folder settings screen, select More settings. samsung security folder settings
  5. Finally, tap the Uninstall option and confirm the uninstallation.uninstall samsung secure folder
  6. When the Samsung Secure folder is uninstalled, try running the ADB commands. It should run without throwing the “Exception occurred while executing” command error.

Add ‘–user 0’ Argument to the ADB Commands

Another simple method to fix the “Exception occurred while executing” command error because “Shell does not have permission to access user 150 is to use the ‘–user 0’ as an argument in your ADB command. If the Samsung Secure Folder is enabled, the ADB Shell commands are directed to ‘user 150’. By adding the ‘–user 0’ argument to your command, you can instruct ADB to bypass ‘user 150’ and direct the command to ‘user 0’, which is the ID of the main user in the Android system.

To make your ADB Shell command work while the Secure Folder is enabled on your Samsung device, add ‘– user 0’ to your command as shown below.

adb shell pm list packages -s --user 0

The command will be executed without any error.add user --0 argument in adb command to fix exception occurred while executing command error

Similarly, to uninstall an Android app package, use the command as follows:

adb shell pm uninstall --user 0 <package-name>

You can use the same workaround to fix the “Exception occurred while executing” command on Samsung devices without root privilege.

Rakesh Shukla

Rakesh Shukla

Rakesh is a geek by heart with an ardent passion for all things tech. From a young age, he was drawn to the world of technology and found himself constantly tinkering with gadgets and devices. He enjoys learning and discovering the newest trends in the world of Android, iOS, and Windows.View Author posts