blob: 8faec1ee20a98f8d039451bb04aafdc16083d284 [file]
' Licensed to the Apache Software Foundation (ASF) under one or more
' contributor license agreements. See the NOTICE file distributed with
' this work for additional information regarding copyright ownership.
' The ASF licenses this file to You under the Apache License, Version 2.0
' (the "License"); you may not use this file except in compliance with
' the License. You may obtain a copy of the License at
'
' http://www.apache.org/licenses/LICENSE-2.0
'
' Unless required by applicable law or agreed to in writing, software
' distributed under the License is distributed on an "AS IS" BASIS,
' WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
' See the License for the specific language governing permissions and
' limitations under the License.
Dim UserAccount
Dim UserPasswd
If WScript.Arguments.Count = 2 Then
UserAccount = WScript.Arguments.Item(0)
UserPasswd = WScript.Arguments.Item(1)
Else
WScript.Echo "Usage: add_user.vbs <user_name> <user_passwd>"
WScript.Quit
End If
strComputer = "."
Set colAccounts = GetObject("WinNT://" & strComputer & "")
Set objUser = colAccounts.Create("user", UserAccount)
objUser.SetPassword UserPasswd
objUser.SetInfo
Set net = WScript.CreateObject("WScript.Network")
local = net.ComputerName
set group = GetObject("WinNT://"& local &"/Administrators")
set group1 = GetObject("WinNT://"& local &"/Remote Desktop Users")
on error resume next
group.Add "WinNT://"& UserAccount &""
group1.Add "WinNT://"& UserAccount &""
CheckError
sub CheckError
if not err.number=0 then
WScript.Echo err.Number
vbCritical err.clear
' else WScript.Echo "Done!"
end if
end sub
WScript.sleep 1000