error in script to change admin to local userSolved

Participant
Discussion
3 years ago

Hey guys,

I recently tried executing a script to change the user from admin privilage to a standard one. The script I have uses a in-script variable to fetch the user that is currently logged in when the script runs. And this variable is used in the commands to change the account type. At first I tried it on the device manually, that succeeded but as I run it through the portal, it failed. When the script output is checked, a curious message is seen “The script execution was terminated abruptly. Please try again when the device is awake and idle.” Does anyone have a clue why this message is popping up.

This is the script I have used:

set var=%userprofile%

set var=%var:C:\Users\=%

net localgroup Users %var% /add

net localgroup Administrators %var% /delete

Replies (1)

Marked SolutionPending Review
Hexnode Expert
3 years ago
Marked SolutionPending Review

Hey @wilson,
Welcome to the Hexnode community.

Currently, fetching the user profile using the Windows wildcard %userprofile% is not possible when executing a custom script through Hexnode UEM. To successfully execute the above script, manually replace the wildcard with the account’s username that needs to be changed from an admin account to a standard account. You can refer to our help documentation for the script to change the account privileges in Windows devices.

Hope that helps your query.
Cheers!
Johan Blake
Hexnode UEM