Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

Add a domain user to local admin account

$
0
0

I am not great with scripts and I'm putting together what I can find on the internet. I work for a college and I am wanting to be able to add a domain user account to the local admin group of a lab full of computers. I have this script and it's working, what I want to do is call a text file and enter all the computers from a lab into that text file and it run the script until all the computers have been completed. Can someone tell me how to call a text file with my script?

strAnswer = InputBox("Please enter a Username:", _
    "Create File")
strAnswer2 = InputBox("Please enter a Computer Name:", _
    "Create File")
Dim DomainName
Dim strAnswer
Set net = WScript.CreateObject("WScript.Network")
local = strAnswer2
DomainName = "some.domain"
UserAccount = strAnswer

set group = GetObject("WinNT://"& local &"/Administrators")

on error resume next
group.Add "WinNT://"& DomainName &"/"& UserAccount &""
CheckError

sub CheckError
if not err.number=0 then
set ole = CreateObject("ole.err")
MsgBox ole.oleError(err.Number), vbCritical
err.clear
else
MsgBox "Done."
end if
end sub

Viewing all articles
Browse latest Browse all 15028

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>