• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# @ohos.enterprise.bundleManager (Bundle Management)
2
3The **bundleManager** module provides APIs for bundle management, including adding, obtaining, and removing a list of bundles that are allowed to install.
4
5> **NOTE**
6>
7> - The initial APIs of this module are supported since API version 10. Newly added APIs will be marked with a superscript to indicate their earliest API version.
8>
9> - The APIs of this module can be used only in the stage model.
10>
11> - The APIs provided by this module can be called only by a [device administrator application](enterpriseDeviceManagement-overview.md#basic-concepts) that is [enabled](js-apis-enterprise-adminManager.md#adminmanagerenableadmin).
12
13## Modules to Import
14
15```ts
16import bundleManager from '@ohos.enterprise.bundleManager';
17```
18
19## bundleManager.addAllowedInstallBundles
20
21addAllowedInstallBundles(admin: Want, appIds: Array\<string>, callback: AsyncCallback&lt;void&gt;): void;
22
23Adds the applications that can be installed by the current user through the specified device administrator application. This API uses an asynchronous callback to return the result.
24
25**Required permissions**: ohos.permission.ENTERPRISE_SET_BUNDLE_INSTALL_POLICY
26
27**System capability**: SystemCapability.Customization.EnterpriseDeviceManager
28
29**System API**: This is a system API.
30
31**Parameters**
32
33| Name     | Type                                      | Mandatory  | Description                      |
34| -------- | ---------------------------------------- | ---- | ------------------------------- |
35| admin    | [Want](js-apis-app-ability-want.md)     | Yes   | Device administrator application.                 |
36| appIds    | Array&lt;string&gt;                | Yes   | IDs of the applications to add.                 |
37| callback | AsyncCallback&lt;void&gt;            | Yes   | Callback invoked to return the result. If the operation is successful, **err** is **null**. Otherwise, **err** is an error object.|
38
39**Error codes**
40
41For details about the error codes, see [Enterprise Device Management Error Codes](../errorcodes/errorcode-enterpriseDeviceManager.md).
42
43| ID| Error Message                                                                      |
44| ------- | ---------------------------------------------------------------------------- |
45| 9200001 | the application is not an administrator of the device.                              |
46| 9200002 | the administrator application does not have permission to manage the device.                                          |
47
48**Example**
49
50```ts
51import Want from '@ohos.app.ability.Want';
52let wantTemp: Want = {
53  bundleName: 'com.example.myapplication',
54  abilityName: 'EntryAbility',
55};
56let appIds: Array<string> = ['com.example.myapplication'];
57
58bundleManager.addAllowedInstallBundles(wantTemp, appIds, (err) => {
59  if (err) {
60    console.error(`Failed to add allowed install bundles. Code is ${err.code}, message is ${err.message}`);
61    return;
62  }
63  console.info('Succeeded in adding allowed install bundles');
64});
65```
66
67## bundleManager.addAllowedInstallBundles
68
69addAllowedInstallBundles(admin: Want, appIds: Array\<string>, userId: number, callback: AsyncCallback&lt;void&gt;): void;
70
71Adds the applications that can be installed by the specified user through the specified device administrator application. This API uses an asynchronous callback to return the result.
72
73**Required permissions**: ohos.permission.ENTERPRISE_SET_BUNDLE_INSTALL_POLICY
74
75**System capability**: SystemCapability.Customization.EnterpriseDeviceManager
76
77**System API**: This is a system API.
78
79**Parameters**
80
81| Name  | Type                                 | Mandatory  | Description     |
82| ----- | ----------------------------------- | ---- | ------- |
83| admin    | [Want](js-apis-app-ability-want.md)     | Yes   | Device administrator application.                 |
84| appIds    | Array&lt;string&gt;                | Yes   | IDs of the applications to add.                 |
85| userId     | number                             | Yes   | User ID, which must be greater than or equal to 0.|
86| callback | AsyncCallback&lt;void&gt;            | Yes   | Callback invoked to return the result. If the operation is successful, **err** is **null**. Otherwise, **err** is an error object.|
87
88**Error codes**
89
90For details about the error codes, see [Enterprise Device Management Error Codes](../errorcodes/errorcode-enterpriseDeviceManager.md).
91
92| ID| Error Message                                                                    |
93| ------- | ---------------------------------------------------------------------------- |
94| 9200001 | the application is not an administrator of the device.                              |
95| 9200002 | the administrator application does not have permission to manage the device.                                          |
96
97**Example**
98
99```ts
100import Want from '@ohos.app.ability.Want';
101let wantTemp: Want = {
102  bundleName: 'com.example.myapplication',
103  abilityName: 'EntryAbility',
104};
105let appIds: Array<string> = ['com.example.myapplication'];
106
107bundleManager.addAllowedInstallBundles(wantTemp, appIds, 100, (err) => {
108  if (err) {
109    console.error(`Failed to add allowed install bundles. Code is ${err.code}, message is ${err.message}`);
110    return;
111  }
112  console.info('Succeeded in adding allowed install bundles');
113});
114```
115
116## bundleManager.addAllowedInstallBundles
117
118addAllowedInstallBundles(admin: Want, appIds: Array\<string>, userId?: number): Promise&lt;void&gt;;
119
120Adds the applications that can be installed by the current or specified user through the specified device administrator application. This API uses a promise to return the result.
121
122**Required permissions**: ohos.permission.ENTERPRISE_SET_BUNDLE_INSTALL_POLICY
123
124**System capability**: SystemCapability.Customization.EnterpriseDeviceManager
125
126**System API**: This is a system API.
127
128**Parameters**
129
130| Name  | Type                                 | Mandatory  | Description     |
131| ----- | ----------------------------------- | ---- | ------- |
132| admin    | [Want](js-apis-app-ability-want.md)     | Yes   | Device administrator application.                 |
133| appIds    | Array&lt;string&gt;                | Yes   | IDs of the applications to add.                 |
134| userId     | number                             | No   |User ID, which must be greater than or equal to 0.<br> - If **userId** is passed in, the applications can be installed by the specified user.<br> - If **userId** is not passed in, the applications can be installed by the current user.|
135
136**Return value**
137
138| Type                  | Description                     |
139| --------------------- | ------------------------- |
140| Promise&lt;void&gt; | Promise that returns no value. If the operation fails, an error object will be thrown. |
141
142**Error codes**
143
144For details about the error codes, see [Enterprise Device Management Error Codes](../errorcodes/errorcode-enterpriseDeviceManager.md).
145
146| ID| Error Message                                                                    |
147| ------- | ---------------------------------------------------------------------------- |
148| 9200001 | the application is not an administrator of the device.                              |
149| 9200002 | the administrator application does not have permission to manage the device.                                          |
150
151**Example**
152
153```ts
154import Want from '@ohos.app.ability.Want';
155import { BusinessError } from '@ohos.base';
156let wantTemp: Want = {
157  bundleName: 'com.example.myapplication',
158  abilityName: 'EntryAbility',
159};
160let appIds: Array<string> = ['com.example.myapplication'];
161
162bundleManager.addAllowedInstallBundles(wantTemp, appIds, 100).then(() => {
163  console.info('Succeeded in adding allowed install bundles');
164}).catch((err: BusinessError) => {
165  console.error(`Failed to add allowed install bundles. Code is ${err.code}, message is ${err.message}`);
166});
167```
168
169## bundleManager.removeAllowedInstallBundles
170
171removeAllowedInstallBundles(admin: Want, appIds: Array\<string>, callback: AsyncCallback&lt;void&gt;): void;
172
173Removes the applications that can be installed by the current user through the specified device administrator application. This API uses an asynchronous callback to return the result.
174
175**Required permissions**: ohos.permission.ENTERPRISE_SET_BUNDLE_INSTALL_POLICY
176
177**System capability**: SystemCapability.Customization.EnterpriseDeviceManager
178
179**System API**: This is a system API.
180
181**Parameters**
182
183| Name     | Type                                      | Mandatory  | Description                      |
184| -------- | ---------------------------------------- | ---- | ------------------------------- |
185| admin    | [Want](js-apis-app-ability-want.md)     | Yes   | Device administrator application.                 |
186| appIds    | Array&lt;string&gt;                | Yes   | IDs of the applications to remove.                 |
187| callback | AsyncCallback&lt;void&gt;            | Yes   | Callback invoked to return the result. If the operation is successful, **err** is **null**. Otherwise, **err** is an error object.|
188
189**Error codes**
190
191For details about the error codes, see [Enterprise Device Management Error Codes](../errorcodes/errorcode-enterpriseDeviceManager.md).
192
193| ID| Error Message                                                                      |
194| ------- | ---------------------------------------------------------------------------- |
195| 9200001 | the application is not an administrator of the device.                              |
196| 9200002 | the administrator application does not have permission to manage the device.                                          |
197
198**Example**
199
200```ts
201import Want from '@ohos.app.ability.Want';
202let wantTemp: Want = {
203  bundleName: 'com.example.myapplication',
204  abilityName: 'EntryAbility',
205};
206let appIds: Array<string> = ['com.example.myapplication'];
207
208bundleManager.removeAllowedInstallBundles(wantTemp, appIds, (err) => {
209  if (err) {
210    console.error(`Failed to remove allowed install bundles. Code is ${err.code}, message is ${err.message}`);
211    return;
212  }
213  console.info('Succeeded in removing allowed install bundles');
214});
215```
216
217## bundleManager.removeAllowedInstallBundles
218
219removeAllowedInstallBundles(admin: Want, appIds: Array\<string>, userId: number, callback: AsyncCallback&lt;void&gt;): void;
220
221Removes the applications that can be installed by the specified user through the specified device administrator application. This API uses an asynchronous callback to return the result.
222
223**Required permissions**: ohos.permission.ENTERPRISE_SET_BUNDLE_INSTALL_POLICY
224
225**System capability**: SystemCapability.Customization.EnterpriseDeviceManager
226
227**System API**: This is a system API.
228
229**Parameters**
230
231| Name  | Type                                 | Mandatory  | Description     |
232| ----- | ----------------------------------- | ---- | ------- |
233| admin    | [Want](js-apis-app-ability-want.md)     | Yes   | Device administrator application.                 |
234| appIds    | Array&lt;string&gt;                | Yes   | IDs of the applications to remove.                 |
235| userId     | number                             | Yes   | User ID, which must be greater than or equal to 0.|
236| callback | AsyncCallback&lt;void&gt;            | Yes   | Callback invoked to return the result. If the operation is successful, **err** is **null**. Otherwise, **err** is an error object.|
237
238**Error codes**
239
240For details about the error codes, see [Enterprise Device Management Error Codes](../errorcodes/errorcode-enterpriseDeviceManager.md).
241
242| ID| Error Message                                                                    |
243| ------- | ---------------------------------------------------------------------------- |
244| 9200001 | the application is not an administrator of the device.                              |
245| 9200002 | the administrator application does not have permission to manage the device.                                          |
246
247**Example**
248
249```ts
250import Want from '@ohos.app.ability.Want';
251let wantTemp: Want = {
252  bundleName: 'com.example.myapplication',
253  abilityName: 'EntryAbility',
254};
255let appIds: Array<string> = ['com.example.myapplication'];
256
257bundleManager.removeAllowedInstallBundles(wantTemp, appIds, 100, (err) => {
258  if (err) {
259    console.error(`Failed to remove allowed install bundles. Code is ${err.code}, message is ${err.message}`);
260    return;
261  }
262  console.info('Succeeded in removing allowed install bundles');
263});
264```
265
266## bundleManager.removeAllowedInstallBundles
267
268removeAllowedInstallBundles(admin: Want, appIds: Array\<string>, userId?: number): Promise&lt;void&gt;;
269
270Removes the applications that can be installed by the current or specified user through the specified device administrator application. This API uses a promise to return the result.
271
272**Required permissions**: ohos.permission.ENTERPRISE_SET_BUNDLE_INSTALL_POLICY
273
274**System capability**: SystemCapability.Customization.EnterpriseDeviceManager
275
276**System API**: This is a system API.
277
278**Parameters**
279
280| Name  | Type                                 | Mandatory  | Description     |
281| ----- | ----------------------------------- | ---- | ------- |
282| admin    | [Want](js-apis-app-ability-want.md)     | Yes   | Device administrator application.                 |
283| appIds    | Array\&lt;string&gt;                | Yes   | IDs of the applications to remove.                 |
284| userId     | number                             | No   | User ID, which must be greater than or equal to 0.<br> - If **userId** is passed in, the applications can be installed by the specified user.<br> - If **userId** is not passed in, the applications can be installed by the current user.|
285
286**Return value**
287
288| Type                  | Description                     |
289| --------------------- | ------------------------- |
290| Promise&lt;void&gt; | Promise that returns no value. If the operation fails, an error object will be thrown. |
291
292**Error codes**
293
294For details about the error codes, see [Enterprise Device Management Error Codes](../errorcodes/errorcode-enterpriseDeviceManager.md).
295
296| ID| Error Message                                                                    |
297| ------- | ---------------------------------------------------------------------------- |
298| 9200001 | the application is not an administrator of the device.                              |
299| 9200002 | the administrator application does not have permission to manage the device.                                          |
300
301**Example**
302
303```ts
304import Want from '@ohos.app.ability.Want';
305import { BusinessError } from '@ohos.base';
306let wantTemp: Want = {
307  bundleName: 'com.example.myapplication',
308  abilityName: 'EntryAbility',
309};
310let appIds: Array<string> = ['com.example.myapplication'];
311
312bundleManager.removeAllowedInstallBundles(wantTemp, appIds, 100).then(() => {
313  console.info('Succeeded in removing allowed install bundles');
314}).catch((err: BusinessError) => {
315  console.error(`Failed to remove allowed install bundles. Code is ${err.code}, message is ${err.message}`);
316});
317```
318
319## bundleManager.getAllowedInstallBundles
320
321getAllowedInstallBundles(admin: Want, callback: AsyncCallback&lt;Array&lt;string&gt;&gt;): void;
322
323Obtains the applications that can be installed by the current user through the specified device administrator application. This API uses an asynchronous callback to return the result.
324
325**Required permissions**: ohos.permission.ENTERPRISE_SET_BUNDLE_INSTALL_POLICY
326
327**System capability**: SystemCapability.Customization.EnterpriseDeviceManager
328
329**System API**: This is a system API.
330
331**Parameters**
332
333| Name     | Type                                      | Mandatory  | Description                      |
334| -------- | ---------------------------------------- | ---- | ------------------------------- |
335| admin    | [Want](js-apis-app-ability-want.md)     | Yes   | Device administrator application.                 |
336| callback | AsyncCallback&lt;Array&lt;string&gt;&gt;       | Yes   | Callback invoked to return the result. If the operation is successful, **err** is **null**. Otherwise, **err** is an error object.      |
337
338**Error codes**
339
340For details about the error codes, see [Enterprise Device Management Error Codes](../errorcodes/errorcode-enterpriseDeviceManager.md).
341
342| ID| Error Message                                                                      |
343| ------- | ---------------------------------------------------------------------------- |
344| 9200001 | the application is not an administrator of the device.                              |
345| 9200002 | the administrator application does not have permission to manage the device.                                          |
346
347**Example**
348
349```ts
350import Want from '@ohos.app.ability.Want';
351let wantTemp: Want = {
352  bundleName: 'com.example.myapplication',
353  abilityName: 'EntryAbility',
354};
355
356bundleManager.getAllowedInstallBundles(wantTemp, (err, result) => {
357  if (err) {
358    console.error(`Failed to get allowed install bundles. Code is ${err.code}, message is ${err.message}`);
359    return;
360  }
361  console.info(`Succeeded in getting allowed install bundles, result : ${JSON.stringify(result)}`);
362});
363```
364
365## bundleManager.getAllowedInstallBundles
366
367getAllowedInstallBundles(admin: Want, userId: number, callback: AsyncCallback&lt;Array&lt;string&gt;&gt;): void;
368
369Obtains the applications that can be installed by the specified user through the specified device administrator application. This API uses an asynchronous callback to return the result.
370
371**Required permissions**: ohos.permission.ENTERPRISE_SET_BUNDLE_INSTALL_POLICY
372
373**System capability**: SystemCapability.Customization.EnterpriseDeviceManager
374
375**System API**: This is a system API.
376
377**Parameters**
378
379| Name     | Type                                      | Mandatory  | Description                      |
380| -------- | ---------------------------------------- | ---- | ------------------------------- |
381| admin    | [Want](js-apis-app-ability-want.md)     | Yes   | Device administrator application.                 |
382| userId     | number                             | Yes   | User ID, which must be greater than or equal to 0.|
383| callback | AsyncCallback&lt;Array&lt;string&gt;&gt;       | Yes   | Callback invoked to return the result. If the operation is successful, **err** is **null**. Otherwise, **err** is an error object.      |
384
385**Error codes**
386
387For details about the error codes, see [Enterprise Device Management Error Codes](../errorcodes/errorcode-enterpriseDeviceManager.md).
388
389| ID| Error Message                                                                      |
390| ------- | ---------------------------------------------------------------------------- |
391| 9200001 | the application is not an administrator of the device.                              |
392| 9200002 | the administrator application does not have permission to manage the device.                                          |
393
394**Example**
395
396```ts
397import Want from '@ohos.app.ability.Want';
398let wantTemp: Want = {
399  bundleName: 'com.example.myapplication',
400  abilityName: 'EntryAbility',
401};
402
403bundleManager.getAllowedInstallBundles(wantTemp, 100, (err, result) => {
404  if (err) {
405    console.error(`Failed to get allowed install bundles. Code is ${err.code}, message is ${err.message}`);
406    return;
407  }
408  console.info(`Succeeded in getting allowed install bundles, result : ${JSON.stringify(result)}`);
409});
410```
411
412## bundleManager.getAllowedInstallBundles
413
414getAllowedInstallBundles(admin: Want, userId?: number): Promise&lt;Array&lt;string&gt;&gt;;
415
416Obtains the applications that can be installed by the current or specified user through the specified device administrator application. This API uses a promise to return the result.
417
418**Required permissions**: ohos.permission.ENTERPRISE_SET_BUNDLE_INSTALL_POLICY
419
420**System capability**: SystemCapability.Customization.EnterpriseDeviceManager
421
422**System API**: This is a system API.
423
424**Parameters**
425
426| Name  | Type                                 | Mandatory  | Description     |
427| ----- | ----------------------------------- | ---- | ------- |
428| admin | [Want](js-apis-app-ability-want.md) | Yes   | Device administrator application.|
429| userId     | number                             | No   | User ID, which must be greater than or equal to 0.<br> - If **userId** is passed in, the applications can be installed by the specified user.<br> - If **userId** is not passed in, the applications can be installed by the current user.|
430
431**Return value**
432
433| Type                  | Description                     |
434| --------------------- | ------------------------- |
435| Promise&lt;Array&lt;string&gt;&gt; | Promise used to return the list of the bundles obtained.|
436
437**Error codes**
438
439For details about the error codes, see [Enterprise Device Management Error Codes](../errorcodes/errorcode-enterpriseDeviceManager.md).
440
441| ID| Error Message                                                                    |
442| ------- | ---------------------------------------------------------------------------- |
443| 9200001 | the application is not an administrator of the device.                              |
444| 9200002 | the administrator application does not have permission to manage the device.                                          |
445
446**Example**
447
448```ts
449import Want from '@ohos.app.ability.Want';
450import { BusinessError } from '@ohos.base';
451let wantTemp: Want = {
452  bundleName: 'com.example.myapplication',
453  abilityName: 'EntryAbility',
454};
455
456bundleManager.getAllowedInstallBundles(wantTemp, 100).then((result) => {
457  console.info(`Succeeded in getting allowed install bundles, result : ${JSON.stringify(result)}`);
458}).catch((err: BusinessError) => {
459  console.error(`Failed to get allowed install bundles. Code is ${err.code}, message is ${err.message}`);
460});
461```
462
463## bundleManager.addDisallowedInstallBundles
464
465addDisallowedInstallBundles(admin: Want, appIds: Array\<string>, callback: AsyncCallback&lt;void&gt;): void;
466
467Adds the applications that cannot be installed by the current user through the specified device administrator application. This API uses an asynchronous callback to return the result.
468
469**Required permissions**: ohos.permission.ENTERPRISE_SET_BUNDLE_INSTALL_POLICY
470
471**System capability**: SystemCapability.Customization.EnterpriseDeviceManager
472
473**System API**: This is a system API.
474
475**Parameters**
476
477| Name     | Type                                      | Mandatory  | Description                      |
478| -------- | ---------------------------------------- | ---- | ------------------------------- |
479| admin    | [Want](js-apis-app-ability-want.md)     | Yes   | Device administrator application.                 |
480| appIds    | Array&lt;string&gt;                | Yes   | IDs of the applications to add.                 |
481| callback | AsyncCallback&lt;void&gt;            | Yes   | Callback invoked to return the result. If the operation is successful, **err** is **null**. Otherwise, **err** is an error object.|
482
483**Error codes**
484
485For details about the error codes, see [Enterprise Device Management Error Codes](../errorcodes/errorcode-enterpriseDeviceManager.md).
486
487| ID| Error Message                                                                      |
488| ------- | ---------------------------------------------------------------------------- |
489| 9200001 | the application is not an administrator of the device.                              |
490| 9200002 | the administrator application does not have permission to manage the device.                                          |
491
492**Example**
493
494```ts
495import Want from '@ohos.app.ability.Want';
496let wantTemp: Want = {
497  bundleName: 'com.example.myapplication',
498  abilityName: 'EntryAbility',
499};
500let appIds: Array<string> = ['com.example.myapplication'];
501
502bundleManager.addDisallowedInstallBundles(wantTemp, appIds, (err) => {
503  if (err) {
504    console.error(`Failed to add disallowed install bundles. Code is ${err.code}, message is ${err.message}`);
505    return;
506  }
507  console.info('Succeeded in adding disallowed install bundles');
508});
509```
510
511## bundleManager.addDisallowedInstallBundles
512
513addDisallowedInstallBundles(admin: Want, appIds: Array\<string>, userId: number, callback: AsyncCallback&lt;void&gt;): void;
514
515Adds the applications that cannot be installed by the specified user through the specified device administrator application. This API uses an asynchronous callback to return the result.
516
517**Required permissions**: ohos.permission.ENTERPRISE_SET_BUNDLE_INSTALL_POLICY
518
519**System capability**: SystemCapability.Customization.EnterpriseDeviceManager
520
521**System API**: This is a system API.
522
523**Parameters**
524
525| Name  | Type                                 | Mandatory  | Description     |
526| ----- | ----------------------------------- | ---- | ------- |
527| admin    | [Want](js-apis-app-ability-want.md)     | Yes   | Device administrator application.                 |
528| appIds    | Array&lt;string&gt;                | Yes   | IDs of the applications to add.                 |
529| userId     | number                             | Yes   | User ID, which must be greater than or equal to 0.|
530| callback | AsyncCallback&lt;void&gt;            | Yes   | Callback invoked to return the result. If the operation is successful, **err** is **null**. Otherwise, **err** is an error object.|
531
532**Error codes**
533
534For details about the error codes, see [Enterprise Device Management Error Codes](../errorcodes/errorcode-enterpriseDeviceManager.md).
535
536| ID| Error Message                                                                    |
537| ------- | ---------------------------------------------------------------------------- |
538| 9200001 | the application is not an administrator of the device.                              |
539| 9200002 | the administrator application does not have permission to manage the device.                                          |
540
541**Example**
542
543```ts
544import Want from '@ohos.app.ability.Want';
545let wantTemp: Want = {
546  bundleName: 'com.example.myapplication',
547  abilityName: 'EntryAbility',
548};
549let appIds: Array<string> = ['com.example.myapplication'];
550
551bundleManager.addDisallowedInstallBundles(wantTemp, appIds, 100, (err) => {
552  if (err) {
553    console.error(`Failed to add disallowed install bundles. Code is ${err.code}, message is ${err.message}`);
554    return;
555  }
556  console.info('Succeeded in adding disallowed install bundles');
557});
558```
559
560## bundleManager.addDisallowedInstallBundles
561
562addDisallowedInstallBundles(admin: Want, appIds: Array\<string>, userId?: number): Promise&lt;void&gt;;
563
564Adds the applications that cannot be installed by the current or specified user through the specified device administrator application. This API uses a promise to return the result.
565
566**Required permissions**: ohos.permission.ENTERPRISE_SET_BUNDLE_INSTALL_POLICY
567
568**System capability**: SystemCapability.Customization.EnterpriseDeviceManager
569
570**System API**: This is a system API.
571
572**Parameters**
573
574| Name  | Type                                 | Mandatory  | Description     |
575| ----- | ----------------------------------- | ---- | ------- |
576| admin    | [Want](js-apis-app-ability-want.md)     | Yes   | Device administrator application.                 |
577| appIds    | Array&lt;string&gt;                | Yes   | IDs of the applications to add.                 |
578| userId     | number                             | No   | User ID, which must be greater than or equal to 0.<br> - If **userId** is passed in, the applications cannot be installed by the specified user.<br> - If **userId** is not passed in, the applications cannot be installed by the current user.|
579
580**Return value**
581
582| Type                  | Description                     |
583| --------------------- | ------------------------- |
584| Promise&lt;void&gt; | Promise that returns no value. If the operation fails, an error object will be thrown. |
585
586**Error codes**
587
588For details about the error codes, see [Enterprise Device Management Error Codes](../errorcodes/errorcode-enterpriseDeviceManager.md).
589
590| ID| Error Message                                                                    |
591| ------- | ---------------------------------------------------------------------------- |
592| 9200001 | the application is not an administrator of the device.                              |
593| 9200002 | the administrator application does not have permission to manage the device.                                          |
594
595**Example**
596
597```ts
598import Want from '@ohos.app.ability.Want';
599import { BusinessError } from '@ohos.base';
600let wantTemp: Want = {
601  bundleName: 'com.example.myapplication',
602  abilityName: 'EntryAbility',
603};
604let appIds: Array<string> = ['com.example.myapplication'];
605
606bundleManager.addDisallowedInstallBundles(wantTemp, appIds, 100).then(() => {
607  console.info('Succeeded in adding disallowed install bundles');
608}).catch((err: BusinessError) => {
609  console.error(`Failed to add disallowed install bundles. Code is ${err.code}, message is ${err.message}`);
610});
611```
612
613## bundleManager.removeDisallowedInstallBundles
614
615removeDisallowedInstallBundles(admin: Want, appIds: Array\<string>, callback: AsyncCallback&lt;void&gt;): void;
616
617Removes the applications that cannot be installed by the current user through the specified device administrator application. This API uses an asynchronous callback to return the result.
618
619**Required permissions**: ohos.permission.ENTERPRISE_SET_BUNDLE_INSTALL_POLICY
620
621**System capability**: SystemCapability.Customization.EnterpriseDeviceManager
622
623**System API**: This is a system API.
624
625**Parameters**
626
627| Name     | Type                                      | Mandatory  | Description                      |
628| -------- | ---------------------------------------- | ---- | ------------------------------- |
629| admin    | [Want](js-apis-app-ability-want.md)     | Yes   | Device administrator application.                 |
630| appIds    | Array&lt;string&gt;                | Yes   | IDs of the applications to remove.                 |
631| callback | AsyncCallback&lt;void&gt;            | Yes   | Callback invoked to return the result. If the operation is successful, **err** is **null**. Otherwise, **err** is an error object.|
632
633**Error codes**
634
635For details about the error codes, see [Enterprise Device Management Error Codes](../errorcodes/errorcode-enterpriseDeviceManager.md).
636
637| ID| Error Message                                                                      |
638| ------- | ---------------------------------------------------------------------------- |
639| 9200001 | the application is not an administrator of the device.                              |
640| 9200002 | the administrator application does not have permission to manage the device.                                          |
641
642**Example**
643
644```ts
645import Want from '@ohos.app.ability.Want';
646let wantTemp: Want = {
647  bundleName: 'com.example.myapplication',
648  abilityName: 'EntryAbility',
649};
650let appIds: Array<string> = ['com.example.myapplication'];
651
652bundleManager.removeDisallowedInstallBundles(wantTemp, appIds, (err) => {
653  if (err) {
654    console.error(`Failed to remove disallowed install bundles. Code is ${err.code}, message is ${err.message}`);
655    return;
656  }
657  console.info('Succeeded in removing disallowed install bundles');
658});
659```
660
661## bundleManager.removeDisallowedInstallBundles
662
663removeDisallowedInstallBundles(admin: Want, appIds: Array\<string>, userId: number, callback: AsyncCallback&lt;void&gt;): void;
664
665Removes the applications that cannot be installed by the specified user through the specified device administrator application. This API uses an asynchronous callback to return the result.
666
667**Required permissions**: ohos.permission.ENTERPRISE_SET_BUNDLE_INSTALL_POLICY
668
669**System capability**: SystemCapability.Customization.EnterpriseDeviceManager
670
671**System API**: This is a system API.
672
673**Parameters**
674
675| Name  | Type                                 | Mandatory  | Description     |
676| ----- | ----------------------------------- | ---- | ------- |
677| admin    | [Want](js-apis-app-ability-want.md)     | Yes   | Device administrator application.                 |
678| appIds    | Array&lt;string&gt;                | Yes   | IDs of the applications to remove.                 |
679| userId     | number                             | Yes   | User ID, which must be greater than or equal to 0.|
680| callback | AsyncCallback&lt;void&gt;            | Yes   | Callback invoked to return the result. If the operation is successful, **err** is **null**. Otherwise, **err** is an error object.|
681
682**Error codes**
683
684For details about the error codes, see [Enterprise Device Management Error Codes](../errorcodes/errorcode-enterpriseDeviceManager.md).
685
686| ID| Error Message                                                                    |
687| ------- | ---------------------------------------------------------------------------- |
688| 9200001 | the application is not an administrator of the device.                              |
689| 9200002 | the administrator application does not have permission to manage the device.                                          |
690
691**Example**
692
693```ts
694import Want from '@ohos.app.ability.Want';
695let wantTemp: Want = {
696  bundleName: 'com.example.myapplication',
697  abilityName: 'EntryAbility',
698};
699let appIds: Array<string> = ['com.example.myapplication'];
700
701bundleManager.removeDisallowedInstallBundles(wantTemp, appIds, 100, (err) => {
702  if (err) {
703    console.error(`Failed to remove disallowed install bundles. Code is ${err.code}, message is ${err.message}`);
704    return;
705  }
706  console.info('Succeeded in removing disallowed install bundles');
707});
708```
709
710## bundleManager.removeDisallowedInstallBundles
711
712removeDisallowedInstallBundles(admin: Want, appIds: Array\<string>, userId?: number): Promise&lt;void&gt;;
713
714Removes the applications that cannot be installed by the current or specified user through the specified device administrator application. This API uses a promise to return the result.
715
716**Required permissions**: ohos.permission.ENTERPRISE_SET_BUNDLE_INSTALL_POLICY
717
718**System capability**: SystemCapability.Customization.EnterpriseDeviceManager
719
720**System API**: This is a system API.
721
722**Parameters**
723
724| Name  | Type                                 | Mandatory  | Description     |
725| ----- | ----------------------------------- | ---- | ------- |
726| admin    | [Want](js-apis-app-ability-want.md)     | Yes   | Device administrator application.                 |
727| appIds    | Array\&lt;string&gt;                | Yes   | IDs of the applications to remove.                 |
728| userId     | number                             | No   | User ID, which must be greater than or equal to 0.<br> - If **userId** is passed in, the applications cannot be installed by the specified user.<br> - If **userId** is not passed in, the applications cannot be installed by the current user.|
729
730**Return value**
731
732| Type                  | Description                     |
733| --------------------- | ------------------------- |
734| Promise&lt;void&gt; | Promise that returns no value. If the operation fails, an error object will be thrown. |
735
736**Error codes**
737
738For details about the error codes, see [Enterprise Device Management Error Codes](../errorcodes/errorcode-enterpriseDeviceManager.md).
739
740| ID| Error Message                                                                    |
741| ------- | ---------------------------------------------------------------------------- |
742| 9200001 | the application is not an administrator of the device.                              |
743| 9200002 | the administrator application does not have permission to manage the device.                                          |
744
745**Example**
746
747```ts
748import Want from '@ohos.app.ability.Want';
749import { BusinessError } from '@ohos.base';
750let wantTemp: Want = {
751  bundleName: 'com.example.myapplication',
752  abilityName: 'EntryAbility',
753};
754let appIds: Array<string> = ['com.example.myapplication'];
755
756bundleManager.removeDisallowedInstallBundles(wantTemp, appIds, 100).then(() => {
757  console.info('Succeeded in removing disallowed install bundles');
758}).catch((err: BusinessError) => {
759  console.error(`Failed to remove disallowed install bundles. Code is ${err.code}, message is ${err.message}`);
760});
761```
762
763## bundleManager.getDisallowedInstallBundles
764
765getDisallowedInstallBundles(admin: Want, callback: AsyncCallback&lt;Array&lt;string&gt;&gt;): void;
766
767Obtains the applications that cannot be installed by the current user through the specified device administrator application. This API uses an asynchronous callback to return the result.
768
769**Required permissions**: ohos.permission.ENTERPRISE_SET_BUNDLE_INSTALL_POLICY
770
771**System capability**: SystemCapability.Customization.EnterpriseDeviceManager
772
773**System API**: This is a system API.
774
775**Parameters**
776
777| Name     | Type                                      | Mandatory  | Description                      |
778| -------- | ---------------------------------------- | ---- | ------------------------------- |
779| admin    | [Want](js-apis-app-ability-want.md)     | Yes   | Device administrator application.                 |
780| callback | AsyncCallback&lt;Array&lt;string&gt;&gt;       | Yes   | Callback invoked to return the result. If the operation is successful, **err** is **null**. Otherwise, **err** is an error object.      |
781
782**Error codes**
783
784For details about the error codes, see [Enterprise Device Management Error Codes](../errorcodes/errorcode-enterpriseDeviceManager.md).
785
786| ID| Error Message                                                                      |
787| ------- | ---------------------------------------------------------------------------- |
788| 9200001 | the application is not an administrator of the device.                              |
789| 9200002 | the administrator application does not have permission to manage the device.                                          |
790
791**Example**
792
793```ts
794import Want from '@ohos.app.ability.Want';
795let wantTemp: Want = {
796  bundleName: 'com.example.myapplication',
797  abilityName: 'EntryAbility',
798};
799
800bundleManager.getDisallowedInstallBundles(wantTemp, (err, result) => {
801  if (err) {
802    console.error(`Failed to get disallowed install bundles. Code is ${err.code}, message is ${err.message}`);
803    return;
804  }
805  console.info(`Succeeded in getting disallowed install bundles, result : ${JSON.stringify(result)}`);
806});
807```
808
809## bundleManager.getDisallowedInstallBundles
810
811getDisallowedInstallBundles(admin: Want, userId: number, callback: AsyncCallback&lt;Array&lt;string&gt;&gt;): void;
812
813Obtains the applications that cannot be installed by the specified user through the specified device administrator application. This API uses an asynchronous callback to return the result.
814
815**Required permissions**: ohos.permission.ENTERPRISE_SET_BUNDLE_INSTALL_POLICY
816
817**System capability**: SystemCapability.Customization.EnterpriseDeviceManager
818
819**System API**: This is a system API.
820
821**Parameters**
822
823| Name     | Type                                      | Mandatory  | Description                      |
824| -------- | ---------------------------------------- | ---- | ------------------------------- |
825| admin    | [Want](js-apis-app-ability-want.md)     | Yes   | Device administrator application.                 |
826| userId     | number                             | Yes   | User ID, which must be greater than or equal to 0.|
827| callback | AsyncCallback&lt;Array&lt;string&gt;&gt;       | Yes   | Callback invoked to return the result. If the operation is successful, **err** is **null**. Otherwise, **err** is an error object.      |
828
829**Error codes**
830
831For details about the error codes, see [Enterprise Device Management Error Codes](../errorcodes/errorcode-enterpriseDeviceManager.md).
832
833| ID| Error Message                                                                      |
834| ------- | ---------------------------------------------------------------------------- |
835| 9200001 | the application is not an administrator of the device.                              |
836| 9200002 | the administrator application does not have permission to manage the device.                                          |
837
838**Example**
839
840```ts
841import Want from '@ohos.app.ability.Want';
842let wantTemp: Want = {
843  bundleName: 'com.example.myapplication',
844  abilityName: 'EntryAbility',
845};
846
847bundleManager.getDisallowedInstallBundles(wantTemp, 100, (err, result) => {
848  if (err) {
849    console.error(`Failed to get disallowed install bundles. Code is ${err.code}, message is ${err.message}`);
850    return;
851  }
852  console.info(`Succeeded in getting disallowed install bundles, result : ${JSON.stringify(result)}`);
853});
854```
855
856## bundleManager.getDisallowedInstallBundles
857
858getDisallowedInstallBundles(admin: Want, userId?: number): Promise&lt;Array&lt;string&gt;&gt;;
859
860Obtains the applications that cannot be installed by the current or specified user through the specified device administrator application. This API uses a promise to return the result.
861
862**Required permissions**: ohos.permission.ENTERPRISE_SET_BUNDLE_INSTALL_POLICY
863
864**System capability**: SystemCapability.Customization.EnterpriseDeviceManager
865
866**System API**: This is a system API.
867
868**Parameters**
869
870| Name  | Type                                 | Mandatory  | Description     |
871| ----- | ----------------------------------- | ---- | ------- |
872| admin | [Want](js-apis-app-ability-want.md) | Yes   | Device administrator application.|
873| userId     | number                             | No   | User ID, which must be greater than or equal to 0.<br> - If **userId** is passed in, the applications cannot be installed by the specified user.<br> - If **userId** is not passed in, the applications cannot be installed by the current user.|
874
875**Return value**
876
877| Type                  | Description                     |
878| --------------------- | ------------------------- |
879| Promise&lt;Array&lt;string&gt;&gt; | Promise used to return the list of the bundles obtained.|
880
881**Error codes**
882
883For details about the error codes, see [Enterprise Device Management Error Codes](../errorcodes/errorcode-enterpriseDeviceManager.md).
884
885| ID| Error Message                                                                    |
886| ------- | ---------------------------------------------------------------------------- |
887| 9200001 | the application is not an administrator of the device.                              |
888| 9200002 | the administrator application does not have permission to manage the device.                                          |
889
890**Example**
891
892```ts
893import Want from '@ohos.app.ability.Want';
894import { BusinessError } from '@ohos.base';
895let wantTemp: Want = {
896  bundleName: 'com.example.myapplication',
897  abilityName: 'EntryAbility',
898};
899
900bundleManager.getDisallowedInstallBundles(wantTemp, 100).then((result) => {
901  console.info(`Succeeded in getting disallowed install bundles, result : ${JSON.stringify(result)}`);
902}).catch((err: BusinessError) => {
903  console.error(`Failed to get disallowed install bundles. Code is ${err.code}, message is ${err.message}`);
904});
905```
906
907## bundleManager.addDisallowedUninstallBundles
908
909addDisallowedUninstallBundles(admin: Want, appIds: Array\<string>, callback: AsyncCallback&lt;void&gt;): void
910
911Adds the applications that cannot be uninstalled by the current user through the specified device administrator application. This API uses an asynchronous callback to return the result.
912
913**Required permissions**: ohos.permission.ENTERPRISE_SET_BUNDLE_INSTALL_POLICY
914
915**System capability**: SystemCapability.Customization.EnterpriseDeviceManager
916
917**System API**: This is a system API.
918
919**Parameters**
920
921| Name     | Type                                      | Mandatory  | Description                      |
922| -------- | ---------------------------------------- | ---- | ------------------------------- |
923| admin    | [Want](js-apis-app-ability-want.md)     | Yes   | Device administrator application.                 |
924| appIds    | Array&lt;string&gt;                | Yes   | IDs of the applications to add.                 |
925| callback | AsyncCallback&lt;void&gt;            | Yes   | Callback invoked to return the result. If the operation is successful, **err** is **null**. Otherwise, **err** is an error object.|
926
927**Error codes**
928
929For details about the error codes, see [Enterprise Device Management Error Codes](../errorcodes/errorcode-enterpriseDeviceManager.md).
930
931| ID| Error Message                                                                      |
932| ------- | ---------------------------------------------------------------------------- |
933| 9200001 | the application is not an administrator of the device.                              |
934| 9200002 | the administrator application does not have permission to manage the device.                                          |
935
936**Example**
937
938```ts
939import Want from '@ohos.app.ability.Want';
940let wantTemp: Want = {
941  bundleName: 'com.example.myapplication',
942  abilityName: 'EntryAbility',
943};
944let appIds: Array<string> = ['com.example.myapplication'];
945
946bundleManager.addDisallowedUninstallBundles(wantTemp, appIds, (err) => {
947  if (err) {
948    console.error(`Failed to add disallowed uninstall bundles. Code is ${err.code}, message is ${err.message}`);
949    return;
950  }
951  console.info('Succeeded in adding disallowed uninstall bundles');
952});
953```
954
955## bundleManager.addDisallowedUninstallBundles
956
957addDisallowedUninstallBundles(admin: Want, appIds: Array\<string>, userId: number, callback: AsyncCallback&lt;void&gt;): void
958
959Adds the applications that cannot be uninstalled by the specified user through the specified device administrator application. This API uses an asynchronous callback to return the result.
960
961**Required permissions**: ohos.permission.ENTERPRISE_SET_BUNDLE_INSTALL_POLICY
962
963**System capability**: SystemCapability.Customization.EnterpriseDeviceManager
964
965**System API**: This is a system API.
966
967**Parameters**
968
969| Name  | Type                                 | Mandatory  | Description     |
970| ----- | ----------------------------------- | ---- | ------- |
971| admin    | [Want](js-apis-app-ability-want.md)     | Yes   | Device administrator application.                 |
972| appIds    | Array&lt;string&gt;                | Yes   | IDs of the applications to add.                 |
973| userId     | number                             | Yes   | User ID, which must be greater than or equal to 0.|
974| callback | AsyncCallback&lt;void&gt;            | Yes   | Callback invoked to return the result. If the operation is successful, **err** is **null**. Otherwise, **err** is an error object.|
975
976**Error codes**
977
978For details about the error codes, see [Enterprise Device Management Error Codes](../errorcodes/errorcode-enterpriseDeviceManager.md).
979
980| ID| Error Message                                                                    |
981| ------- | ---------------------------------------------------------------------------- |
982| 9200001 | the application is not an administrator of the device.                              |
983| 9200002 | the administrator application does not have permission to manage the device.                                          |
984
985**Example**
986
987```ts
988import Want from '@ohos.app.ability.Want';
989let wantTemp: Want = {
990  bundleName: 'com.example.myapplication',
991  abilityName: 'EntryAbility',
992};
993let appIds: Array<string> = ['com.example.myapplication'];
994
995bundleManager.addDisallowedUninstallBundles(wantTemp, appIds, 100, (err) => {
996  if (err) {
997    console.error(`Failed to add disallowed uninstall bundles. Code is ${err.code}, message is ${err.message}`);
998    return;
999  }
1000  console.info('Succeeded in adding disallowed uninstall bundles');
1001});
1002```
1003
1004## bundleManager.addDisallowedUninstallBundles
1005
1006addDisallowedUninstallBundles(admin: Want, appIds: Array\<string>, userId?: number): Promise&lt;void&gt;
1007
1008Adds the applications that cannot be uninstalled by the current or specified user through the specified device administrator application. This API uses a promise to return the result.
1009
1010**Required permissions**: ohos.permission.ENTERPRISE_SET_BUNDLE_INSTALL_POLICY
1011
1012**System capability**: SystemCapability.Customization.EnterpriseDeviceManager
1013
1014**System API**: This is a system API.
1015
1016**Parameters**
1017
1018| Name  | Type                                 | Mandatory  | Description     |
1019| ----- | ----------------------------------- | ---- | ------- |
1020| admin    | [Want](js-apis-app-ability-want.md)     | Yes   | Device administrator application.                 |
1021| appIds    | Array&lt;string&gt;                | Yes   | IDs of the applications to add.                 |
1022| userId     | number                             | No   | User ID, which must be greater than or equal to 0.<br> - If **userId** is passed in, the applications cannot be uninstalled by the specified user.<br> - If **userId** is not passed in, the applications cannot be uninstalled by the current user.|
1023
1024**Return value**
1025
1026| Type                  | Description                     |
1027| --------------------- | ------------------------- |
1028| Promise&lt;void&gt; | Promise that returns no value. If the operation fails, an error object will be thrown. |
1029
1030**Error codes**
1031
1032For details about the error codes, see [Enterprise Device Management Error Codes](../errorcodes/errorcode-enterpriseDeviceManager.md).
1033
1034| ID| Error Message                                                                    |
1035| ------- | ---------------------------------------------------------------------------- |
1036| 9200001 | the application is not an administrator of the device.                              |
1037| 9200002 | the administrator application does not have permission to manage the device.                                          |
1038
1039**Example**
1040
1041```ts
1042import Want from '@ohos.app.ability.Want';
1043import { BusinessError } from '@ohos.base';
1044let wantTemp: Want = {
1045  bundleName: 'com.example.myapplication',
1046  abilityName: 'EntryAbility',
1047};
1048let appIds: Array<string> = ['com.example.myapplication'];
1049
1050bundleManager.addDisallowedUninstallBundles(wantTemp, appIds, 100).then(() => {
1051  console.info('Succeeded in adding disallowed uninstall bundles');
1052}).catch((err: BusinessError) => {
1053  console.error(`Failed to add disallowed uninstall bundles. Code is ${err.code}, message is ${err.message}`);
1054});
1055```
1056
1057## bundleManager.removeDisallowedUninstallBundles
1058
1059removeDisallowedUninstallBundles(admin: Want, appIds: Array\<string>, callback: AsyncCallback&lt;void&gt;): void
1060
1061Removes the applications that cannot be uninstalled by the current user through the specified device administrator application. This API uses an asynchronous callback to return the result.
1062
1063**Required permissions**: ohos.permission.ENTERPRISE_SET_BUNDLE_INSTALL_POLICY
1064
1065**System capability**: SystemCapability.Customization.EnterpriseDeviceManager
1066
1067**System API**: This is a system API.
1068
1069**Parameters**
1070
1071| Name     | Type                                      | Mandatory  | Description                      |
1072| -------- | ---------------------------------------- | ---- | ------------------------------- |
1073| admin    | [Want](js-apis-app-ability-want.md)     | Yes   | Device administrator application.                 |
1074| appIds    | Array&lt;string&gt;                | Yes   | IDs of the applications to remove.                 |
1075| callback | AsyncCallback&lt;void&gt;            | Yes   | Callback invoked to return the result. If the operation is successful, **err** is **null**. Otherwise, **err** is an error object.|
1076
1077**Error codes**
1078
1079For details about the error codes, see [Enterprise Device Management Error Codes](../errorcodes/errorcode-enterpriseDeviceManager.md).
1080
1081| ID| Error Message                                                                      |
1082| ------- | ---------------------------------------------------------------------------- |
1083| 9200001 | the application is not an administrator of the device.                              |
1084| 9200002 | the administrator application does not have permission to manage the device.                                          |
1085
1086**Example**
1087
1088```ts
1089import Want from '@ohos.app.ability.Want';
1090let wantTemp: Want = {
1091  bundleName: 'com.example.myapplication',
1092  abilityName: 'EntryAbility',
1093};
1094let appIds: Array<string> = ['com.example.myapplication'];
1095
1096bundleManager.removeDisallowedUninstallBundles(wantTemp, appIds, (err) => {
1097  if (err) {
1098    console.error(`Failed to remove disallowed uninstall bundles. Code is ${err.code}, message is ${err.message}`);
1099    return;
1100  }
1101  console.info('Succeeded in removing disallowed uninstall bundles');
1102});
1103```
1104
1105## bundleManager.removeDisallowedUninstallBundles
1106
1107removeDisallowedUninstallBundles(admin: Want, appIds: Array\<string>, userId: number, callback: AsyncCallback&lt;void&gt;): void
1108
1109Removes the applications that cannot be uninstalled by the specified user through the specified device administrator application. This API uses an asynchronous callback to return the result.
1110
1111**Required permissions**: ohos.permission.ENTERPRISE_SET_BUNDLE_INSTALL_POLICY
1112
1113**System capability**: SystemCapability.Customization.EnterpriseDeviceManager
1114
1115**System API**: This is a system API.
1116
1117**Parameters**
1118
1119| Name  | Type                                 | Mandatory  | Description     |
1120| ----- | ----------------------------------- | ---- | ------- |
1121| admin    | [Want](js-apis-app-ability-want.md)     | Yes   | Device administrator application.                 |
1122| appIds    | Array&lt;string&gt;                | Yes   | IDs of the applications to remove.                 |
1123| userId     | number                             | Yes   | User ID, which must be greater than or equal to 0.|
1124| callback | AsyncCallback&lt;void&gt;            | Yes   | Callback invoked to return the result. If the operation is successful, **err** is **null**. Otherwise, **err** is an error object.|
1125
1126**Error codes**
1127
1128For details about the error codes, see [Enterprise Device Management Error Codes](../errorcodes/errorcode-enterpriseDeviceManager.md).
1129
1130| ID| Error Message                                                                    |
1131| ------- | ---------------------------------------------------------------------------- |
1132| 9200001 | the application is not an administrator of the device.                              |
1133| 9200002 | the administrator application does not have permission to manage the device.                                          |
1134
1135**Example**
1136
1137```ts
1138import Want from '@ohos.app.ability.Want';
1139let wantTemp: Want = {
1140  bundleName: 'com.example.myapplication',
1141  abilityName: 'EntryAbility',
1142};
1143let appIds: Array<string> = ['com.example.myapplication'];
1144
1145bundleManager.removeDisallowedUninstallBundles(wantTemp, appIds, 100, (err) => {
1146  if (err) {
1147    console.error(`Failed to remove disallowed uninstall bundles. Code is ${err.code}, message is ${err.message}`);
1148    return;
1149  }
1150  console.info('Succeeded in removing disallowed uninstall bundles');
1151});
1152```
1153
1154## bundleManager.removeDisallowedUninstallBundles
1155
1156removeDisallowedUninstallBundles(admin: Want, appIds: Array\<string>, userId?: number): Promise&lt;void&gt;
1157
1158Removes the applications that cannot be uninstalled by the current or specified user through the specified device administrator application. This API uses a promise to return the result.
1159
1160**Required permissions**: ohos.permission.ENTERPRISE_SET_BUNDLE_INSTALL_POLICY
1161
1162**System capability**: SystemCapability.Customization.EnterpriseDeviceManager
1163
1164**System API**: This is a system API.
1165
1166**Parameters**
1167
1168| Name  | Type                                 | Mandatory  | Description     |
1169| ----- | ----------------------------------- | ---- | ------- |
1170| admin    | [Want](js-apis-app-ability-want.md)     | Yes   | Device administrator application.                 |
1171| appIds    | Array\&lt;string&gt;                | Yes   | IDs of the applications to remove.                 |
1172| userId     | number                             | No   | User ID, which must be greater than or equal to 0.<br> - If **userId** is passed in, the applications cannot be uninstalled by the specified user.<br> - If **userId** is not passed in, the applications cannot be uninstalled by the current user.|
1173
1174**Return value**
1175
1176| Type                  | Description                     |
1177| --------------------- | ------------------------- |
1178| Promise&lt;void&gt; | Promise that returns no value. If the operation fails, an error object will be thrown. |
1179
1180**Error codes**
1181
1182For details about the error codes, see [Enterprise Device Management Error Codes](../errorcodes/errorcode-enterpriseDeviceManager.md).
1183
1184| ID| Error Message                                                                    |
1185| ------- | ---------------------------------------------------------------------------- |
1186| 9200001 | the application is not an administrator of the device.                              |
1187| 9200002 | the administrator application does not have permission to manage the device.                                          |
1188
1189**Example**
1190
1191```ts
1192import Want from '@ohos.app.ability.Want';
1193import { BusinessError } from '@ohos.base';
1194let wantTemp: Want = {
1195  bundleName: 'com.example.myapplication',
1196  abilityName: 'EntryAbility',
1197};
1198let appIds: Array<string> = ['com.example.myapplication'];
1199
1200bundleManager.removeDisallowedUninstallBundles(wantTemp, appIds, 100).then(() => {
1201  console.info('Succeeded in removing disallowed uninstall bundles');
1202}).catch((err: BusinessError) => {
1203  console.error(`Failed to remove disallowed uninstall bundles. Code is ${err.code}, message is ${err.message}`);
1204});
1205```
1206
1207## bundleManager.getDisallowedUninstallBundles
1208
1209getDisallowedUninstallBundles(admin: Want, callback: AsyncCallback&lt;Array&lt;string&gt;&gt;): void
1210
1211Obtains the applications that cannot be uninstalled by the current user through the specified device administrator application. This API uses an asynchronous callback to return the result.
1212
1213**Required permissions**: ohos.permission.ENTERPRISE_SET_BUNDLE_INSTALL_POLICY
1214
1215**System capability**: SystemCapability.Customization.EnterpriseDeviceManager
1216
1217**System API**: This is a system API.
1218
1219**Parameters**
1220
1221| Name     | Type                                      | Mandatory  | Description                      |
1222| -------- | ---------------------------------------- | ---- | ------------------------------- |
1223| admin    | [Want](js-apis-app-ability-want.md)     | Yes   | Device administrator application.                 |
1224| callback | AsyncCallback&lt;Array&lt;string&gt;&gt;       | Yes   | Callback invoked to return the result. If the operation is successful, **err** is **null**. Otherwise, **err** is an error object.      |
1225
1226**Error codes**
1227
1228For details about the error codes, see [Enterprise Device Management Error Codes](../errorcodes/errorcode-enterpriseDeviceManager.md).
1229
1230| ID| Error Message                                                                      |
1231| ------- | ---------------------------------------------------------------------------- |
1232| 9200001 | the application is not an administrator of the device.                              |
1233| 9200002 | the administrator application does not have permission to manage the device.                                          |
1234
1235**Example**
1236
1237```ts
1238import Want from '@ohos.app.ability.Want';
1239let wantTemp: Want = {
1240  bundleName: 'com.example.myapplication',
1241  abilityName: 'EntryAbility',
1242};
1243
1244bundleManager.getDisallowedUninstallBundles(wantTemp, (err, result) => {
1245  if (err) {
1246    console.error(`Failed to get disallowed uninstall bundles. Code is ${err.code}, message is ${err.message}`);
1247    return;
1248  }
1249  console.info(`Succeeded in getting disallowed uninstall bundles, result : ${JSON.stringify(result)}`);
1250});
1251```
1252
1253## bundleManager.getDisallowedUninstallBundles
1254
1255getDisallowedUninstallBundles(admin: Want, userId: number, callback: AsyncCallback&lt;Array&lt;string&gt;&gt;): void
1256
1257Obtains the applications that cannot be uninstalled by the specified user through the specified device administrator application. This API uses an asynchronous callback to return the result.
1258
1259**Required permissions**: ohos.permission.ENTERPRISE_SET_BUNDLE_INSTALL_POLICY
1260
1261**System capability**: SystemCapability.Customization.EnterpriseDeviceManager
1262
1263**System API**: This is a system API.
1264
1265**Parameters**
1266
1267| Name     | Type                                      | Mandatory  | Description                      |
1268| -------- | ---------------------------------------- | ---- | ------------------------------- |
1269| admin    | [Want](js-apis-app-ability-want.md)     | Yes   | Device administrator application.                 |
1270| userId     | number                             | Yes   | User ID, which must be greater than or equal to 0.|
1271| callback | AsyncCallback&lt;Array&lt;string&gt;&gt;       | Yes   | Callback invoked to return the result. If the operation is successful, **err** is **null**. Otherwise, **err** is an error object.      |
1272
1273**Error codes**
1274
1275For details about the error codes, see [Enterprise Device Management Error Codes](../errorcodes/errorcode-enterpriseDeviceManager.md).
1276
1277| ID| Error Message                                                                      |
1278| ------- | ---------------------------------------------------------------------------- |
1279| 9200001 | the application is not an administrator of the device.                              |
1280| 9200002 | the administrator application does not have permission to manage the device.                                          |
1281
1282**Example**
1283
1284```ts
1285import Want from '@ohos.app.ability.Want';
1286let wantTemp: Want = {
1287  bundleName: 'com.example.myapplication',
1288  abilityName: 'EntryAbility',
1289};
1290
1291bundleManager.getDisallowedUninstallBundles(wantTemp, 100, (err, result) => {
1292  if (err) {
1293    console.error(`Failed to get disallowed uninstall bundles. Code is ${err.code}, message is ${err.message}`);
1294    return;
1295  }
1296  console.info(`Succeeded in getting disallowed uninstall bundles, result : ${JSON.stringify(result)}`);
1297});
1298```
1299
1300## bundleManager.getDisallowedUninstallBundles
1301
1302getDisallowedUninstallBundles(admin: Want, userId?: number): Promise&lt;Array&lt;string&gt;&gt;
1303
1304Obtains the applications that cannot be uninstalled by the current or specified user through the specified device administrator application. This API uses a promise to return the result.
1305
1306**Required permissions**: ohos.permission.ENTERPRISE_SET_BUNDLE_INSTALL_POLICY
1307
1308**System capability**: SystemCapability.Customization.EnterpriseDeviceManager
1309
1310**System API**: This is a system API.
1311
1312**Parameters**
1313
1314| Name  | Type                                 | Mandatory  | Description     |
1315| ----- | ----------------------------------- | ---- | ------- |
1316| admin | [Want](js-apis-app-ability-want.md) | Yes   | Device administrator application.|
1317| userId     | number                             | No   | User ID, which must be greater than or equal to 0.<br> - If **userId** is passed in, the applications cannot be uninstalled by the specified user.<br> - If **userId** is not passed in, the applications cannot be uninstalled by the current user.|
1318
1319**Return value**
1320
1321| Type                  | Description                     |
1322| --------------------- | ------------------------- |
1323| Promise&lt;Array&lt;string&gt;&gt; | Promise used to return the bundle list obtained.|
1324
1325**Error codes**
1326
1327For details about the error codes, see [Enterprise Device Management Error Codes](../errorcodes/errorcode-enterpriseDeviceManager.md).
1328
1329| ID| Error Message                                                                    |
1330| ------- | ---------------------------------------------------------------------------- |
1331| 9200001 | the application is not an administrator of the device.                              |
1332| 9200002 | the administrator application does not have permission to manage the device.                                          |
1333
1334**Example**
1335
1336```ts
1337import Want from '@ohos.app.ability.Want';
1338import { BusinessError } from '@ohos.base';
1339let wantTemp: Want = {
1340  bundleName: 'com.example.myapplication',
1341  abilityName: 'EntryAbility',
1342};
1343
1344bundleManager.getDisallowedUninstallBundles(wantTemp, 100).then((result) => {
1345  console.info(`Succeeded in getting disallowed uninstall bundles, result : ${JSON.stringify(result)}`);
1346}).catch((err: BusinessError) => {
1347  console.error(`Failed to get disallowed uninstall bundles. Code is ${err.code}, message is ${err.message}`);
1348});
1349```
1350
1351## bundleManager.uninstall
1352
1353uninstall(admin: Want, bundleName: string, callback: AsyncCallback&lt;void&gt;): void
1354
1355Uninstalls an application of the current user without retaining the bundle data through the specified device administrator application. This API uses an asynchronous callback to return the result.
1356
1357**Required permissions**: ohos.permission.ENTERPRISE_INSTALL_BUNDLE
1358
1359**System capability**: SystemCapability.Customization.EnterpriseDeviceManager
1360
1361**System API**: This is a system API.
1362
1363**Parameters**
1364
1365| Name     | Type                                      | Mandatory  | Description                      |
1366| -------- | ---------------------------------------- | ---- | ------------------------------- |
1367| admin    | [Want](js-apis-app-ability-want.md)     | Yes   | Device administrator application.                 |
1368| bundleName     | string                             | Yes   | Name of the bundle to uninstall.|
1369| callback | AsyncCallback&lt;void&gt;       | Yes   | Callback invoked to return the result. If the operation is successful, **err** is **null**. Otherwise, **err** is an error object.      |
1370
1371**Error codes**
1372
1373For details about the error codes, see [Enterprise Device Management Error Codes](../errorcodes/errorcode-enterpriseDeviceManager.md).
1374
1375| ID| Error Message                                                                      |
1376| ------- | ---------------------------------------------------------------------------- |
1377| 9200001 | the application is not an administrator of the device.                              |
1378| 9200002 | the administrator application does not have permission to manage the device.                                          |
1379
1380**Example**
1381
1382```ts
1383import Want from '@ohos.app.ability.Want';
1384let wantTemp: Want = {
1385  bundleName: 'com.example.myapplication',
1386  abilityName: 'EntryAbility',
1387};
1388
1389bundleManager.uninstall(wantTemp, 'bundleName', (err) => {
1390  if (err) {
1391    console.error(`Failed to uninstall bundles. Code is ${err.code}, message is ${err.message}`);
1392  }
1393  console.info('Succeeded in uninstalling bundles');
1394});
1395```
1396
1397## bundleManager.uninstall
1398
1399uninstall(admin: Want, bundleName: string, userId: number, callback: AsyncCallback&lt;void&gt;): void
1400
1401Uninstalls an application of the specified user without retaining the bundle data through the specified device administrator application. This API uses an asynchronous callback to return the result.
1402
1403**Required permissions**: ohos.permission.ENTERPRISE_INSTALL_BUNDLE
1404
1405**System capability**: SystemCapability.Customization.EnterpriseDeviceManager
1406
1407**System API**: This is a system API.
1408
1409**Parameters**
1410
1411| Name     | Type                                      | Mandatory  | Description                      |
1412| -------- | ---------------------------------------- | ---- | ------------------------------- |
1413| admin    | [Want](js-apis-app-ability-want.md)     | Yes   | Device administrator application.                 |
1414| bundleName     | string                             | Yes   | Name of the bundle to uninstall.|
1415| userId     | number                             | Yes   | User ID, which must be greater than or equal to 0.|
1416| callback | AsyncCallback&lt;void&gt;       | Yes   | Callback invoked to return the result. If the operation is successful, **err** is **null**. Otherwise, **err** is an error object.      |
1417
1418**Error codes**
1419
1420For details about the error codes, see [Enterprise Device Management Error Codes](../errorcodes/errorcode-enterpriseDeviceManager.md).
1421
1422| ID| Error Message                                                                      |
1423| ------- | ---------------------------------------------------------------------------- |
1424| 9200001 | the application is not an administrator of the device.                              |
1425| 9200002 | the administrator application does not have permission to manage the device.                                          |
1426
1427**Example**
1428
1429```ts
1430import Want from '@ohos.app.ability.Want';
1431let wantTemp: Want = {
1432  bundleName: 'com.example.myapplication',
1433  abilityName: 'EntryAbility',
1434};
1435
1436bundleManager.uninstall(wantTemp, 'bundleName', 100, (err) => {
1437  if (err) {
1438    console.error(`Failed to uninstall bundles. Code is ${err.code}, message is ${err.message}`);
1439  }
1440  console.info('Succeeded in uninstalling bundles');
1441});
1442```
1443
1444## bundleManager.uninstall
1445
1446uninstall(admin: Want, bundleName: string, isKeepData: boolean, callback: AsyncCallback&lt;void&gt;): void
1447
1448Uninstalls an application of the current user through the specified device administrator application. The **isKeepData** parameter specifies whether to retain the bundle data. This API uses an asynchronous callback to return the result.
1449
1450**Required permissions**: ohos.permission.ENTERPRISE_INSTALL_BUNDLE
1451
1452**System capability**: SystemCapability.Customization.EnterpriseDeviceManager
1453
1454**System API**: This is a system API.
1455
1456**Parameters**
1457
1458| Name     | Type                                      | Mandatory  | Description                      |
1459| -------- | ---------------------------------------- | ---- | ------------------------------- |
1460| admin    | [Want](js-apis-app-ability-want.md)     | Yes   | Device administrator application.                 |
1461| bundleName     | string                             | Yes   | Name of the bundle to uninstall.|
1462| isKeepData     | boolean                             | Yes   | Whether to retain the bundle data. The value **true** means to retain the bundle data; the value **false** means the opposite.|
1463| callback | AsyncCallback&lt;void&gt;       | Yes   | Callback invoked to return the result. If the operation is successful, **err** is **null**. Otherwise, **err** is an error object.      |
1464
1465**Error codes**
1466
1467For details about the error codes, see [Enterprise Device Management Error Codes](../errorcodes/errorcode-enterpriseDeviceManager.md).
1468
1469| ID| Error Message                                                                      |
1470| ------- | ---------------------------------------------------------------------------- |
1471| 9200001 | the application is not an administrator of the device.                              |
1472| 9200002 | the administrator application does not have permission to manage the device.                                          |
1473
1474**Example**
1475
1476```ts
1477import Want from '@ohos.app.ability.Want';
1478let wantTemp: Want = {
1479  bundleName: 'com.example.myapplication',
1480  abilityName: 'EntryAbility',
1481};
1482
1483bundleManager.uninstall(wantTemp, 'bundleName', true, (err) => {
1484  if (err) {
1485    console.error(`Failed to uninstall bundles. Code is ${err.code}, message is ${err.message}`);
1486  }
1487  console.info('Succeeded in uninstalling bundles');
1488});
1489```
1490
1491## bundleManager.uninstall
1492
1493uninstall(admin: Want, bundleName: string, userId: number, isKeepData: boolean, callback: AsyncCallback&lt;void&gt;): void
1494
1495Uninstalls an application of the specified user through the specified device administrator application. The **isKeepData** parameter specifies whether to retain the bundle data. This API uses an asynchronous callback to return the result.
1496
1497**Required permissions**: ohos.permission.ENTERPRISE_INSTALL_BUNDLE
1498
1499**System capability**: SystemCapability.Customization.EnterpriseDeviceManager
1500
1501**System API**: This is a system API.
1502
1503**Parameters**
1504
1505| Name     | Type                                      | Mandatory  | Description                      |
1506| -------- | ---------------------------------------- | ---- | ------------------------------- |
1507| admin    | [Want](js-apis-app-ability-want.md)     | Yes   | Device administrator application.                 |
1508| bundleName     | string                             | Yes   | Name of the bundle to uninstall.|
1509| userId     | number                             | Yes   | User ID, which must be greater than or equal to 0.|
1510| isKeepData     | boolean                             | Yes   | Whether to retain the bundle data. The value **true** means to retain the bundle data; the value **false** means the opposite.|
1511| callback | AsyncCallback&lt;void&gt;       | Yes   | Callback invoked to return the result. If the operation is successful, **err** is **null**. Otherwise, **err** is an error object.      |
1512
1513**Error codes**
1514
1515For details about the error codes, see [Enterprise Device Management Error Codes](../errorcodes/errorcode-enterpriseDeviceManager.md).
1516
1517| ID| Error Message                                                                      |
1518| ------- | ---------------------------------------------------------------------------- |
1519| 9200001 | the application is not an administrator of the device.                              |
1520| 9200002 | the administrator application does not have permission to manage the device.                                          |
1521
1522**Example**
1523
1524```ts
1525import Want from '@ohos.app.ability.Want';
1526let wantTemp: Want = {
1527  bundleName: 'com.example.myapplication',
1528  abilityName: 'EntryAbility',
1529};
1530
1531bundleManager.uninstall(wantTemp, 'bundleName', 100, true, (err) => {
1532  if (err) {
1533    console.error(`Failed to uninstall bundles. Code is ${err.code}, message is ${err.message}`);
1534  }
1535  console.info('Succeeded in uninstalling bundles');
1536});
1537```
1538
1539## bundleManager.uninstall
1540
1541uninstall(admin: Want, bundleName: string, userId?: number, isKeepData?: boolean): Promise&lt;void&gt;
1542
1543Uninstalls an application of the current or specified user through the specified device administrator application. The **isKeepData** parameter specifies whether to retain the bundle data. This API uses a promise to return the result.
1544
1545**Required permissions**: ohos.permission.ENTERPRISE_INSTALL_BUNDLE
1546
1547**System capability**: SystemCapability.Customization.EnterpriseDeviceManager
1548
1549**System API**: This is a system API.
1550
1551**Parameters**
1552
1553| Name  | Type                                 | Mandatory  | Description     |
1554| ----- | ----------------------------------- | ---- | ------- |
1555| admin | [Want](js-apis-app-ability-want.md) | Yes   | Device administrator application.|
1556| bundleName     | string                             | Yes   | Name of the bundle to uninstall.|
1557| userId     | number                             | No   | User ID, which must be greater than or equal to 0.<br> - If **userId** is passed in, the application of the specified user is uninstalled.<br> - If **userId** is not passed in, the application of the current user is uninstalled.|
1558| isKeepData     | boolean                             | No   | Whether to retain the bundle data. The value **true** means to retain the bundle data; the value **false** means the opposite.|
1559
1560**Return value**
1561
1562| Type                  | Description                     |
1563| --------------------- | ------------------------- |
1564| Promise&lt;void&gt; | Promise that returns no value. An error object will be thrown if the bundle fails to be uninstalled.|
1565
1566**Error codes**
1567
1568For details about the error codes, see [Enterprise Device Management Error Codes](../errorcodes/errorcode-enterpriseDeviceManager.md).
1569
1570| ID| Error Message                                                                    |
1571| ------- | ---------------------------------------------------------------------------- |
1572| 9200001 | the application is not an administrator of the device.                              |
1573| 9200002 | the administrator application does not have permission to manage the device.                                          |
1574
1575**Example**
1576
1577```ts
1578import Want from '@ohos.app.ability.Want';
1579import { BusinessError } from '@ohos.base';
1580let wantTemp: Want = {
1581  bundleName: 'com.example.myapplication',
1582  abilityName: 'EntryAbility',
1583};
1584
1585bundleManager.uninstall(wantTemp, 'bundleName', 100, true).then(() => {
1586  console.info('Succeeded in uninstalling bundles');
1587}).catch((err: BusinessError) => {
1588  console.error(`Failed to uninstall bundles. Code is ${err.code}, message is ${err.message}`);
1589});
1590```
1591
1592## bundleManager.install
1593
1594install(admin: Want, hapFilePaths: Array\<string>, callback: AsyncCallback\<void>): void
1595
1596Installs applications through the specified device administrator application. This API uses an asynchronous callback to return the result.
1597
1598**Required permissions**: ohos.permission.ENTERPRISE_INSTALL_BUNDLE
1599
1600**System capability**: SystemCapability.Customization.EnterpriseDeviceManager
1601
1602**System API**: This is a system API.
1603
1604**Parameters**
1605
1606| Name     | Type                                      | Mandatory  | Description                      |
1607| -------- | ---------------------------------------- | ---- | ------------------------------- |
1608| admin    | [Want](js-apis-app-ability-want.md)     | Yes   | Device administrator application.                 |
1609| hapFilePaths     | Array\<string>                           | Yes   | Applications to install.|
1610| callback | AsyncCallback&lt;void&gt;       | Yes   | Callback invoked to return the result. If the operation is successful, **err** is **null**. Otherwise, **err** is an error object.      |
1611
1612**Error codes**
1613
1614For details about the error codes, see [Enterprise Device Management Error Codes](../errorcodes/errorcode-enterpriseDeviceManager.md).
1615
1616| ID| Error Message                                                                      |
1617| ------- | ---------------------------------------------------------------------------- |
1618| 9200001 | the application is not an administrator of the device.                              |
1619| 9200002 | the administrator application does not have permission to manage the device.                                |
1620| 9201002 | the application install failed.                                |
1621
1622**Example**
1623
1624```ts
1625import Want from '@ohos.app.ability.Want';
1626let wantTemp: Want = {
1627  bundleName: 'com.example.myapplication',
1628  abilityName: 'EntryAbility',
1629};
1630let hapFilePaths: Array<string> = ['/data/storage/el2/base/haps/entry/testinstall/ExtensionTest.hap']
1631
1632bundleManager.install(wantTemp, hapFilePaths, (err) => {
1633  if (err) {
1634    console.error(`Failed to install bundles. Code is ${err.code}, message is ${err.message}`);
1635  }
1636  console.info('Succeeded in installing bundles');
1637});
1638```
1639
1640## bundleManager.install
1641
1642install(admin: Want, hapFilePaths: Array\<string>, installParam: InstallParam, callback: AsyncCallback\<void>): void
1643
1644Installs applications with specified parameters through the specified device administrator application. This API uses an asynchronous callback to return the result.
1645
1646**Required permissions**: ohos.permission.ENTERPRISE_INSTALL_BUNDLE
1647
1648**System capability**: SystemCapability.Customization.EnterpriseDeviceManager
1649
1650**System API**: This is a system API.
1651
1652**Parameters**
1653
1654| Name     | Type                                      | Mandatory  | Description                      |
1655| -------- | ---------------------------------------- | ---- | ------------------------------- |
1656| admin    | [Want](js-apis-app-ability-want.md)     | Yes   | Device administrator application.                 |
1657| hapFilePaths     | Array\<string>                       | Yes   | Applications to install.|
1658| installParam     | [InstallParam](#installparam)        | Yes   | Application installation parameters.|
1659| callback | AsyncCallback&lt;void&gt;       | Yes   | Callback invoked to return the result. If the operation is successful, **err** is **null**. Otherwise, **err** is an error object.      |
1660
1661**Error codes**
1662
1663For details about the error codes, see [Enterprise Device Management Error Codes](../errorcodes/errorcode-enterpriseDeviceManager.md).
1664
1665| ID| Error Message                                                                      |
1666| ------- | ---------------------------------------------------------------------------- |
1667| 9200001 | the application is not an administrator of the device.                              |
1668| 9200002 | the administrator application does not have permission to manage the device.                                |
1669| 9201002 | the application install failed.                                |
1670
1671**Example**
1672
1673```ts
1674import Want from '@ohos.app.ability.Want';
1675let wantTemp: Want = {
1676  bundleName: 'com.example.myapplication',
1677  abilityName: 'EntryAbility',
1678};
1679let hapFilePaths: Array<string> = ['/data/storage/el2/base/haps/entry/testinstall/ExtensionTest.hap']
1680let installParam: bundleManager.InstallParam = {
1681  userId: 100,
1682  installFlag: 1,
1683};
1684
1685bundleManager.install(wantTemp, hapFilePaths, installParam, (err) => {
1686  if (err) {
1687    console.error(`Failed to install bundles. Code is ${err.code}, message is ${err.message}`);
1688  }
1689  console.info('Succeeded in installing bundles');
1690});
1691```
1692
1693## bundleManager.install
1694
1695install(admin: Want, hapFilePaths: Array\<string>, installParam?: InstallParam): Promise\<void>
1696
1697Installs applications through the specified device administrator application. This API uses a promise to return the result.
1698
1699**Required permissions**: ohos.permission.ENTERPRISE_INSTALL_BUNDLE
1700
1701**System capability**: SystemCapability.Customization.EnterpriseDeviceManager
1702
1703**System API**: This is a system API.
1704
1705**Parameters**
1706
1707| Name  | Type                                 | Mandatory  | Description     |
1708| ----- | ----------------------------------- | ---- | ------- |
1709| admin | [Want](js-apis-app-ability-want.md) | Yes   | Device administrator application.|
1710| hapFilePaths     | Array\<string>                       | Yes   | Applications to install.|
1711| installParam     | [InstallParam](#installparam)        | No   | Application installation parameters.|
1712
1713**Return value**
1714
1715| Type                  | Description                     |
1716| --------------------- | ------------------------- |
1717| Promise&lt;void&gt; | Promise that returns no value. If the operation fails, an error object will be thrown.|
1718
1719**Error codes**
1720
1721For details about the error codes, see [Enterprise Device Management Error Codes](../errorcodes/errorcode-enterpriseDeviceManager.md).
1722
1723| ID| Error Message                                                                    |
1724| ------- | ---------------------------------------------------------------------------- |
1725| 9200001 | the application is not an administrator of the device.                              |
1726| 9200002 | the administrator application does not have permission to manage the device.                                          |
1727| 9201002 | the application install failed.                                |
1728
1729**Example**
1730
1731```ts
1732import Want from '@ohos.app.ability.Want';
1733import { BusinessError } from '@ohos.base';
1734let wantTemp: Want = {
1735  bundleName: 'com.example.myapplication',
1736  abilityName: 'EntryAbility',
1737};
1738let hapFilePaths: Array<string> = ['/data/storage/el2/base/haps/entry/testinstall/ExtensionTest.hap']
1739
1740bundleManager.install(wantTemp, hapFilePaths).then(() => {
1741  console.info('Succeeded in installing bundles');
1742}).catch((err: BusinessError) => {
1743  console.error(`Failed to install bundles. Code is ${err.code}, message is ${err.message}`);
1744});
1745```
1746
1747## InstallParam
1748
1749Defines the parameters specified for installing applications.
1750
1751 **System capability**: SystemCapability.Customization.EnterpriseDeviceManager
1752
1753 **System API**: This is a system API.
1754
1755| Name                       | Type                          | Mandatory                        | Description              |
1756| ------------------------------ | ------------------------------ | ------------------ | ------------------ |
1757| userId                         | number                         | No                       | User ID, which must be greater than or equal to 0. The default value is the user ID of the caller. |
1758| installFlag                    | number                         | No                       | Installation flag.<br>- **0**: initial installation.<br>- **1**: overwrite installation.<br>- **2**: installation-free.<br>Default value: **0** |
1759
1760