Stace
Mon Feb 04 04:41:16 CST 2008
"tony" <tony@web.com> wrote in message
news:e7yn3lIZIHA.4332@TK2MSFTNGP04.phx.gbl...
>I have a list of the computers in a file, line after line. how can i have
>it read the file and then run the script
>
>
> "Stace" <this@does.not.work> wrote in message
> news:u5zeGLDZIHA.536@TK2MSFTNGP06.phx.gbl...
>> "tony" <tony@web.com> wrote in message
>> news:O5WUg8CZIHA.4684@TK2MSFTNGP06.phx.gbl...
>>>I am looking for a script that will create a local username and set
>>>password for the user on 50 computers. The computers are all in workgroup
>>
>> Tony,
>> I used the following script:
>>
>> -------------
>> Script Start
>> -------------
>> ' specify account to create
>> strAccount = "newAdmin"
>> strPswd = "newPassword"
>>
>> ' get local computer name
>> Set objNetwork = CreateObject("Wscript.Network")
>> strComputer = objNetwork.ComputerName
>>
>> ' check if local account already exists
>> intExists = 0
>> Set colAccounts = GetObject("WinNT://" & strComputer & "")
>> colAccounts.Filter = Array("user")
>> For Each objUser In colAccounts
>> If objUser.Name = strAccount Then
>> intExists = 1
>> End If
>> Next
>>
>> If intExists = 0 Then
>> ' create local user
>> Set colAccounts = GetObject("WinNT://" & strComputer & "")
>> Set objUser = colAccounts.Create("user", strAccount)
>>
>> ' set pswd
>> objUser.SetPassword strPswd
>> objUser.SetInfo
>>
>> ' set pswd never expires
>> Set objUser = GetObject("WinNT://" & strComputer & "/" & strAccount &
>> ",User")
>> objUserFlags = objUser.Get("UserFlags")
>> objPasswordExpirationFlag = objUserFlags Or ADS_UF_DONT_EXPIRE_PASSWD
>> objUser.Put "userFlags", objPasswordExpirationFlag
>> objUser.SetInfo
>>
>> ' add to local admins group
>> Set objGroup = GetObject("WinNT://" & strComputer &
>> "/Administrators,group")
>> Set objUser = GetObject("WinNT://" & strComputer & "/" & strAccount &
>> ",user")
>> objGroup.Add(objUser.ADsPath)
>> End If
>>
>> -------------
>> Script End
>> -------------
>>
>> The secret is that this needs to run under an existing local
>> administrator account. I used AdminScriptEditor to package this as an EXE
>> and specified the alternative credentials (local admin account) in the
>> Script Packager section.
>>
>> All you then have to do is get it run on each PC.
>>
>> Hope this gives you some ideas.
>> Stace.
>>
>>
Hi Tony,
Take a look at this web page to get some ideas:
http://www.computerperformance.co.uk/vbscript/wmi_process_start.htm
They do have a sample script that prompts for a computer name. You would
just need to change this for a process loop that reads your file of computer
names and executes once fro each name.
HTH
Stace.