A script to add a local user to the administrators group, ensuring it runs with administrator privileges.
This script is designed to add a specified local user to the administrators group on a Windows machine. It ensures that the script runs with administrator privileges by relaunching itself with predefined credentials if necessary.
- Windows operating system
- Administrator credentials
- Clone the Repository:
git clone https://github.com/YOUR_USERNAME/AddUserToAdminGroup.git cd AddUserToAdminGroup
- Open AddUserToAdminGroup.au3 in a text editor.
- Replace ENTER ADMIN USERNAME and ENTER ADMIN PASSWORD with the actual administrator username and password.
Execute the script using an AutoIt interpreter or compile it to an executable.
The script performs the following steps:
-
Check for Administrator Privileges: If the script is not running as an administrator, it relaunches itself with the provided administrator credentials.
-
Prompt for User Account: Prompts the user to enter the username of the account to be added to the administrators group.
-
Add User to Administrators Group: Uses the net localgroup command to add the specified user to the local administrators group.
-
Confirm Success: Displays a message indicating whether the user was successfully added to the administrators group.
-
Optional Restart: Prompts the user to restart the computer immediately or later.