Re: Script for creating a new user
Katheryne wrote:
Hi
I want to create a local user.
Hi,
1)
With command line:
Creating local user jeanette with the password some password:
net.exe user jeanette /ADD "some password"
2)
Creating a local user and adding it to the Administrators group
using VBScript and the WinNT provider:
'--------------------8<----------------------
' name of user to be created
sNewUser = "mini-strator"
' password to be set on the account
sPassword = "A1234_B1234"
' name of the group the user is to be added to
sGroupname = "Administrators"
' get computer name, using current computer in this case
Set oWshNet = CreateObject("WScript.Network")
sComputerName = oWshNet.ComputerName
' connect to the Winnt provider
Set oComputer = GetObject("WinNT://" & sComputerName)
' create the user
Set oUser = oComputer.Create("user", sNewUser)
oUser.SetPassword sPassword
' in case the user already exists, we suppress the error
On Error Resume Next
' create the user
oUser.Setinfo
' Add the user to the group
Set oGroup = GetObject("WinNT://" & sComputerName & "/" & sGroupname)
' Use error handling in case the account is a member already
On Error Resume Next
oGroup.Add(oUser.ADsPath)
On Error Goto 0
'--------------------8<----------------------
--
torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway
Administration scripting examples and an ONLINE version of
the 1328 page Scripting Guide:
http://www.microsoft.com/technet/scriptcenter/default.mspx
.
Relevant Pages
- Re: Script
... If you do not know scripting you would need someone to customize ... to see the complete membership of the administrators group. ... If you see an account xxx that should be removed you may issue ... net localgroup administrators xxx /delete ... (microsoft.public.windows.server.security) - Re: Scripting remote WMI problem
... Just that the account on my ... computer that i know for certain to have admin rights on the domain server ... is listed only as the member of Administrators group, ... > torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway ... (microsoft.public.windowsxp.general) - Re: Script for creating a new user
... how would I start to write these scripting frm scratch ... >> I want to create a local user. ... > using VBScript and the WinNT provider: ... > ' Use error handling in case the account is a member already ... (microsoft.public.scripting.vbscript) - Add a local user in a Restricted Group GPO
... Account to do is work. ... Administrators group, and don't see a way to add a local user in the GPO ... (microsoft.public.windows.group_policy) - Re: Promoting an user to a power user
... > member of more groups. ... > Account in Control Panel, which allows to switch between Computer ... > Administrators group and Users group, how could I switch between them? ... -- torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway Administration scripting examples and an ONLINE version of the 1328 page Scripting Guide: ... (microsoft.public.windowsxp.security_admin) |
|