# @ohos.enterprise.deviceControl(设备控制管ç†ï¼‰ 本模å—æ供设备控制能力。 > **说明**: > > 本模å—首批接å£ä»ŽAPI version 12 开始支æŒã€‚åŽç»ç‰ˆæœ¬çš„新增接å£ï¼Œé‡‡ç”¨ä¸Šè§’æ ‡å•ç‹¬æ ‡è®°æŽ¥å£çš„起始版本。 > > 本模å—接å£ä»…å¯åœ¨Stage模型下使用。 > > 本模å—接å£ä»…对[设备管ç†åº”用](../../mdm/mdm-kit-guide.md#功能介ç»)开放,需将设备管ç†åº”用激活åŽè°ƒç”¨ï¼Œå®žçŽ°ç›¸åº”功能。 ## å¯¼å…¥æ¨¡å— ```ts import { deviceControl } from '@kit.MDMKit'; ``` ## deviceControl.operateDevice operateDevice(admin: Want, operate: string, addition?: string): void å…许管ç†å‘˜æ“作设备。 **需è¦æƒé™ï¼š** ohos.permission.ENTERPRISE_OPERATE_DEVICE **系统能力:** SystemCapability.Customization.EnterpriseDeviceManager **å‚数:** | å‚æ•°å | 类型 | å¿…å¡« | 说明 | | -------- | ------------------------------------------------------- | ---- | ------------------------------------------------------------ | | admin | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | 是 | 设备管ç†åº”用。 | | operate | string | 是 | è¦æ‰§è¡Œçš„æ“作。<br/>- resetFactory:设备æ¢å¤å‡ºåŽ‚设置。<br/>- reboot:设备é‡å¯ã€‚<br/>- shutDown:设备关机。<br/>- lockScreen:设备å±å¹•é”定。 <!--RP1--><!--RP1End-->| | addition | string | å¦ | <!--RP2-->æ‰§è¡Œæ—¶é™„åŠ å‚数。目å‰æ— éœ€ä¼ å…¥ã€‚<!--RP2End--> | **错误ç :** 以下错误ç 的详细介ç»è¯·å‚è§[ä¼ä¸šè®¾å¤‡ç®¡ç†é”™è¯¯ç ](errorcode-enterpriseDeviceManager.md)å’Œ[通用错误ç ](../errorcode-universal.md)。 | 错误ç ID | é”™è¯¯ä¿¡æ¯ | | -------- | ------------------------------------------------------------ | | 9200001 | The application is not an administrator application of the device. | | 9200002 | The administrator application does not have permission to manage the device. | | 201 | Permission verification failed. The application does not have the permission required to call the API. | | 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | **示例:** ```ts import { deviceControl } from '@kit.MDMKit'; import { Want } from '@kit.AbilityKit'; let wantTemp: Want = { bundleName: 'com.example.myapplication', abilityName: 'EntryAbility', }; try { deviceControl.operateDevice(wantTemp, 'resetFactory'); } catch (err) { console.error(`Failed to reset factory. Code is ${err.code}, message is ${err.message}`); } ```