Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Disable Guest Account

Status
Not open for further replies.

lrmerc

Technical User
Nov 7, 2003
20
0
0
GB
I have a vbscript which now resets the Password for local guest and administrator accounts. I would also like to disable the guest account anyone know of an easy way to do this? Im new to this so help is appreciated. Local guest name is currently in GuestName as this changes from site to site....

Thanks
 
Try the following:

strComputer = "MyComputer"
Set objUser = GetObject("WinNT://" & strComputer & "/Guest")
objUser.AccountDisabled = True
objUser.SetInfo

 
Irmerc can you post your change administrator script. I need to change the admin pw on a bunch of machines,

Thank
 
The code follows. It could have been written a lot tydier but i have only just started looking at VB scripts. First 8 lines is where I read in the password from a file this is so password can be inputted on a web page and will automatically change the admin passwords Via group policy in windows 2000. Let me know if it doesn't make sense..... Works though which is a good sign!!!!

Cheers

on error resume next

Const ForReading = 1, ForWriting = 2, ForAppending = 8
Dim fso, ts, strg
Set fso = CreateObject("Scripting.FileSystemObject")
Set ts = fso_OpenTextFile("\\SERVER1\passwords\sitename.txt", ForReading)
Dim password
counter = 0
do while not ts.AtEndOfStream
counter = counter+1
password = ts.readline
loop
password = Replace(password, """", "")
ts.close

Dim objNet
Set objNet = Createobject("WScript.Network")
Dim AdminName
Dim GuestName
AdminName = "uk01admin"
GuestName = "uk01guest"
Dim computer
computer = objNet.ComputerName

If InStr(1, computer, "wlap" ,VBTextcompare) > 0 Then

Dim User1
Dim User2
Set User1 = GetObject ("WinNT://" & computer & "/"& AdminName &"",user)
Call User1.SetPassword(password)
Set User2 = GetObject ("WinNT://" & computer & "/"& GuestName &"",user)
Call User2.SetPassword(password)

end if

If InStr(1, computer, "wwks" ,VBTextcompare) > 0 Then

Dim User3
Dim User4
Set User3 = GetObject ("WinNT://" & computer & "/"& AdminName &"",user)
Call User3.SetPassword(password)
Set User4 = GetObject ("WinNT://" & computer & "/"& GuestName &"",user)
Call User4.SetPassword(password)

end if

Set objNet = Nothing
 
I am trying to do something similar to both of these at once...to run them through a login script. I was going to place the "password.txt" file on a local ADC server drive and place the script in the login script location (for security.) doing this when I run a combination of the above two script I get an error "The network path was not found." This appears to happen regardless of the script location. Could you help me out?

Here is what I have:
Const ForReading = 1, ForWriting = 2, ForAppending = 8
Dim fso, ts, password, AdminName, computer
Set fso = CreateObject("Scripting.FileSystemObject")
Set password = fso_OpenTextFile("\\SERVER1\passowrd.txt", ForReading)
ts.close

Dim objNet
Set objNet = Createobject("WScript.Network")
AdminName = "Administrator"
computer = objNet.ComputerName

If InStr(1, computer, "wlap" ,VBTextcompare) > 0 Then

Dim User1
Set User1 = GetObject ("WinNT://" & computer & "/"& AdminName &"",user)
Call User1.SetPassword(password)

end if

Set objNet = Nothing
strComputer = "MyComputer"
Set objUser = GetObject("WinNT://" & strComputer & "/Guest")
objUser.AccountDisabled = True
objUser.SetInfo

Thanks,
Alex
 
Ya you probably need to remove the IF.... This line <If InStr(1, computer, &quot;wlap&quot; ,VBTextcompare) > 0 Then> This applies only to my company as wlap is contained in the naming standard.... It can be removed altogether

Also remove the end if!

Cheers Lloyd

 
Ok, I am lost, let me start a new thread...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top