NC4x4 Scripters I need help

bonecrusher

Well-Known Member
Joined
Mar 13, 2007
Location
Indian Trail, NC
My needs : A VBS script that takes all LOCAL users and Disables every account over 90 days old.

So far I have a script that creates a txt file and puts all local usernames on it.

I also have a script that will print name and lastlogon but will only do it one username at a time(script below)
I'm still stumped as to how to connect the two.

Here is my code so far

Dim objuser
Dim objUserClass
Dim objProperty
strComputer = "."

Set objUser = GetObject("WinNT://"& strComputer & "/LOCALUSER,user")
Set ObjUserClass = GetObject(objUser.Schema)

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile("c:\user_status1.txt", 8, True)

ObjTextFile.WriteLine (objUser.Name)
ObjTextFile.WriteLine (objUser.LastLogin)


********************************

It's simple and it works
Only problem is LOCALUSER has to be inputed one at a time.

I have a txt file with all usernames in it seperated by a vbcrlf arguement.
This is driving me nutso.

also as I'm looking at it if the user was created and never logged on it won't return any value and error out.

after I get the script to print out username and lastlogon in a text file then I need to create a vbs script that disables all Local Usernames in that text file.

UGH
 
Dude, What language are you typing in. Did you say you need a 9/16" wrench? Wished I could help...
 
I got pissed off enough to say screw it.

I created a passthrough arguement and made up a batchfile to solve the problem kinda.

freaking computers.
this is why I like Carbs
 
Why output to a text file at all? Loop through the collection of users executing the code to disable the accounts that haven't logged on in 90 days. I'd use a "For Each" loop. I assume you already have the code to disable the accounts? I haven't written vb script in years.
 
I do not interpent what you endeaver to convey.
 
chris

I ended up with 5 different scripts.

scripta outputs all users to a text file

scriptb outputs all users from text filea into a new text file and sorts by login date

scriptc creates a text file that only has usernames that are inactive or 90 days old

scriptd disables all usernames on the text file from script c

scripte runs them all in sequence.

so cumbersome and definitely not good coding practice but i don't know how to function with pass-through variables in vbscript
 
Well as long as you got it working the way you need it then I wouldn't worry about how clunky it is since it's such a simple procedure.
 
Back
Top