create a basic script to create a local user account on a computer and restrict a defined set of permissions. in python

Here is a basic script to create a new local user account and restrict permissions:

main.py
import os

# set username and password for new user
username = "new_user"
password = "password123"

# create new user account
os.system("net user /add " + username + " " + password)

# restrict permissions for new user
os.system("net localgroup Users " + username + " /delete")
os.system("net localgroup Guests " + username + " /add")
335 chars
13 lines

This script uses the os module to execute command-line commands. The net user command is used to create a new user account with the specified username and password. The net localgroup command is used to delete the new user from the Users group (which has more permissions) and add them to the Guests group (which has fewer permissions).

Note that this script should be run with administrative privileges to be able to create new user accounts and manage user groups.

related categories

gistlibby LogSnag